我们手动转发和发送电子邮件的时间与使用宏转发Outlook中的电子邮件之间的差异

时间:2017-10-04 00:59:55

标签: vba outlook outlook-vba forwarding

我没有注意到使用outlook手动转发电子邮件(2016)前进按钮给出了与使用宏转发时不同的结果。这是我的宏:

Sub W()

Dim helpdeskaddress As String
Dim objMail As Outlook.MailItem
Dim strbody As String
Dim oldmsg As String
Dim senderaddress As String
Dim addresstype As Integer

' Set this variable as your helpdesk e-mail address
helpdeskaddress = "blah@blah.com"

Set objItem = GetCurrentItem()
Set objMail = objItem.Forward

' Sender E=mail Address
senderaddress = objItem.SenderEmailAddress

'Searches for @ in the email address to determine if it is an exchange user
addresstype = InStr(senderaddress, "@")

' If the address is an Exchange DN use the Senders Name
If addresstype = 0 Then
senderaddress = objItem.SenderName
End If

'adds the senders e-mail address as the created by object for the ticket and appends the message body
strbody = "#created by " & senderaddress & vbNewLine & vbNewLine & objItem.Body

objMail.To = "receiver@blah.com"
objMail.Subject = objItem.Subject
objMail.Body = strbody

' remove the comment from below to display the message before sending
'objMail.Display

'Automatically Send the ticket
objMail.Send
MsgBox ("The email has been sent for verification. You may receive a report in a few moments.")

Set objItem = Nothing
Set objMail = Nothing
End Sub

以及获取当前电子邮件对象项的函数:

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application
Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
  Case "Explorer"
    Set GetCurrentItem = _
    objApp.ActiveExplorer.Selection.Item(1)
  Case "Inspector"
    Set GetCurrentItem = _
    objApp.ActiveInspector.CurrentItem
  Case Else
End Select
End Function

当我转发电子邮件时,我可以看到我转发的所有图像(链接到互联网上的其他网站),但是当我使用以下宏时,我看到的只是电子邮件中的文字。无论如何我可以使下面的宏做手动转发类似的工作吗?

1 个答案:

答案 0 :(得分:1)

要转发原始内容,请使用HTMLBody代替Body

strbody = "HTML-encoded content"

objMail.HTMLBody = strbody & objMail.HTMLBody

示例HTML Format specific text in Outlook