VBA to forward an email

妖精的绣舞 提交于 2019-12-10 11:41:23

问题


I have designed a macro to forward an email. The below code drafts a forward email, adds some information in the body, retains the original content at the bottom of the email. But the only problem is, when the macro attempts to forward the email, the original format is getting lost.

Also, by default, it displays my email id as From Address. Instead, it should be "ops@ccorp.com". Could you please help me?

Sub Forward_Email()
Set objOL = CreateObject("Outlook.Application")
Set objMsg = objOL.ActiveInspector.CurrentItem
Set objForward = objMsg.Forward
objForward.Recipients.Add "someone@example.com"
objForward.CC = "eg1@example.com"
objOrignialBody = objForward.Body
Workbooks.Open Filename:= _
"C:\Users\desktop\Email Distribution Control File.xlsx"
Sheets("Incorrect Device Type").Select
EmailLastRow = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row
Cells.Find(What:="Subject", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Activate
BodyofEmail = ActiveCell.Value
ActiveCell.Offset(1, 0).Activate
For emailrange = 6 To EmailLastRow - 1
If ActiveCell.Row > EmailLastRow Then
GoTo DraftEmail
Else
End If
BodyofEmail = BodyofEmail & vbCrLf & ActiveCell.Value
ActiveCell.Offset(1, 0).Activate
Next emailrange
DraftEmail:
objForward.Display
objForward.Body = BodyofEmail & vbCr & vbCr & vbCr & objOrignialBody

回答1:


Try adding the following code to the end of your code to send the email on behalf off opsccorp@com:

objforward.SentOnBehalfOfName = "ops@ccorp.com"


来源:https://stackoverflow.com/questions/16361769/vba-to-forward-an-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!