我们手动转发和发送电子邮件时与我们使用宏在 Outlook 中转发电子邮件时的区别
Differences between when we manually forward and email versus when we use a macro to forward an email in outlook
我没有注意到使用 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
当我转发一封电子邮件时,我可以看到我转发的所有图片(链接到互联网上的另一个网站)但是当我使用以下宏时,我看到的只是电子邮件中的文本。无论如何我可以让下面的宏来完成与手动转发类似的工作吗?
转发原创内容,请使用HTMLBody
代替Body
:
strbody = "HTML-encoded content"
objMail.HTMLBody = strbody & objMail.HTMLBody
样本HTML
我没有注意到使用 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
当我转发一封电子邮件时,我可以看到我转发的所有图片(链接到互联网上的另一个网站)但是当我使用以下宏时,我看到的只是电子邮件中的文本。无论如何我可以让下面的宏来完成与手动转发类似的工作吗?
转发原创内容,请使用HTMLBody
代替Body
:
strbody = "HTML-encoded content"
objMail.HTMLBody = strbody & objMail.HTMLBody
样本HTML