IT Knowledge Base

~ Without sacrifice, there can be no victory ~

發佈日期:

如何在Microsoft Outlook中‧為轉寄郵件時加入原來所有人電郵地址

01. 另一同事提到在Outlookl中需要『回覆郵件時加入原來附件』功能,但之前使用的巨集,對某些電郵中的嵌入物件出現錯誤,要不不附加有關嵌入物件,又或者如今次標題一樣,她需要的是『轉寄郵件時加入原來所有人電郵地址』功能。

02. 程式碼很簡單,就是執行巨集直接轉寄電郵。但因為轉寄時,電郵內原有的地址也會被刪除,所以要建立一封暫用電郵,再將所有電郵地址複製到轉寄電郵內,再刪除暫用電郵。而因應複製的電郵地址,會以X500格式顯示出來,所以每加入一個電郵,也會同時對電郵作一次『解繹 (Resolve)』動作。

03. 程式碼。

Sub ForwardWithAllAddress()
Dim oReply As Outlook.MailItem
Dim myinspector As Outlook.Inspector
Dim tempItem, myItem As Outlook.MailItem
Dim myattachments As Outlook.Attachments
Dim myDelegate As Outlook.Recipient
Set myinspector = Application.ActiveInspector
If Not TypeName(myinspector) = "Nothing" Then
Set myItem = ActiveExplorer.Selection.item(1).Forward
myItem.Display
Set tempItem = ActiveExplorer.Selection.item(1)
Set oReply = tempItem.ReplyAll
oReply.Save
For i = 1 To oReply.Recipients.count
Set myDelegate = myItem.Recipients.Add(oReply.Recipients.item(i).Address)
myDelegate.Resolve
Next
oReply.Delete
Else
MsgBox "There is no active inspector."
End If
End Sub

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *