2017-06-22 399 views
0

我有以下腳本可以運行,該腳本將模板中的電子郵件確認發送給與共享郵箱聯繫的外部用戶。每週大約一次或兩次,我遇到了標題欄中列出的錯誤。Outlook VB腳本:Outlook無法識別一個或多個名稱

您是否能夠協助提供代碼,以便忽略無法解析的電子郵件地址,並且如果可能的話在發生這種情況時通知我一條消息?

對不起,我以前設置此一兩年,學習就足以得到這個工作:/


Sub AutoReplywithTemplate(Item As Outlook.MailItem) 
Dim oRespond As Outlook.MailItem 

' Use this for a real reply 
' Set oRespond = Item.Reply 

' This sends a response back using a template 
Set oRespond = Application.CreateItemFromTemplate("C:\Users\dannygonzales\AppData\Roaming\Microsoft\Templates\GMS Technical Support Email Acknowledgment (Default).oft") 

With oRespond 
.Recipients.Add Item.SenderEmailAddress 
.Subject = "GMS Technical Support Acknowledgement" 
.HTMLBody = vbCrLf & oRespond.HTMLBody 

' includes the original message as an attachment 
' .Attachments.Add Item 

' use this for testing, change to .send once you have it working as desired 
.Send 
End With 
Set oRespond = Nothing 
End Sub 

回答

0

使用Recipients.ResolveAll方法;如果任何收件人的地址有問題,它將返回False。您可以評估Recipient.Resolved收集每個成員以確定哪一個是無效的。

+0

謝謝,埃裏克!我很欣賞這種迴應! – DannyG73