2017-06-22 405 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