2013-05-03 398 views
1

我設計了一個宏來轉發電子郵件。下面的代碼起草了一封電子郵件,在正文中添加了一些信息,並保留了電子郵件底部的原始內容。但唯一的問題是,當宏嘗試轉發電子郵件時,原始格式正在丟失。VBA轉發電子郵件

此外,默認情況下,它顯示我的電子郵件ID爲From Address。相反,它應該是「[email protected]」。你可以幫我嗎?

Sub Forward_Email() 
Set objOL = CreateObject("Outlook.Application") 
Set objMsg = objOL.ActiveInspector.CurrentItem 
Set objForward = objMsg.Forward 
objForward.Recipients.Add "[email protected]" 
objForward.CC = "[email protected]" 
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 
+0

什麼格式迷路?電子郵件的格式(即Rich Text vs. HTML vs.純文本)還是Excel單元格格式(您在此代碼中未捕獲的格式)? – 2013-05-03 16:37:50

+0

嗨大衛,HTML格式正在迷失。這些信息對你有幫助嗎? – user2341632 2013-05-03 17:22:26

+0

試試這個:http://stackoverflow.com/questions/15758300/excel-vba-formatting-of-outlook-signature-is-gone – 2013-05-03 17:28:21

回答

0

嘗試添加以下代碼到你的代碼的末尾發送電子郵件代表關opsccorp @ COM:

objforward.SentOnBehalfOfName = "[email protected]"