我有以下脚本要运行,它会将模板中的电子邮件确认发送给联系共享邮箱的外部用户。大约每周一次或两次我遇到标题字段中列出的错误。
您是否可以协助提供忽略无法解析的电子邮件地址的代码,如果可能的话,还会发出一条消息,以便在发生这种情况时通知我?
对不起,我在几年前就已经设置了这个并且学到了足够的知识来实现这个目的:/
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 :(得分:0)
使用Recipients.ResolveAll方法;如果任何收件人的地址出现问题,它将返回False。您可以为集合的每个成员评估Recipient.Resolved以确定哪个成员无效。