检查senderEmailAddress [英] Check for the senderEmailAddress

查看:210
本文介绍了检查senderEmailAddress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果从特定电子邮件中收到邮件,我的Outlook框上的VBA中有一个侦听器可以执行操作.

I have a listener in VBA on my outlook box to perform an action if a receive a mail from a specific email.

问题是,如果收到错误邮件(未送达的电子邮件),那么我的条件将在不具有该属性的邮件上运行,因此我的方法将崩溃.

The problem is that if I get a error mail (non-delivery email) then my condition is run on a mail which doesn't have that property so my method crashes.

我也不知道主题可能是什么.

I don't know what the subject may be either.

有人能知道我是否可以测试该属性是否存在,或者是否可以检查另一个属性以识别我的发件人是否匹配?

Does anyone have an idea if I can test if the property exists or if there is another property I can check for to identify if my sender matches?

非常感谢

Sub SetFlagIcon() 

 Dim mpfInbox As Outlook.Folder 

 Dim obj As Outlook.MailItem 

 Dim i As Integer 



 Set mpfInbox = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Test") 

 ' Loop all items in the Inbox\Test Folder 

 For i = 1 To mpfInbox.Items.Count 

 If mpfInbox.Items(i).Class = olMail Then 

 Set obj = mpfInbox.Items.Item(i) 

 If obj.SenderEmailAddress = "someone@example.com" Then 

 'Set the yellow flag icon 

 obj.FlagIcon = olYellowFlagIcon 

 obj.Save 

 End If 

 End If 

 Next 

End Sub

推荐答案

Dim obj as a generic Object -除了 在您的收件箱中 MailItem ,也可以使用


项目集合,返回一个新集合,其中包含来自原始内容的所有与过滤器匹配的项目.

Items.Restrict Method Applies a filter to the Items collection, returning a new collection containing all of the items from the original that match the filter.

这篇关于检查senderEmailAddress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆