Vbscript 使用VB脚本从outlook中的特定地址获取未读电子邮件

Vbscript 使用VB脚本从outlook中的特定地址获取未读电子邮件,vbscript,outlook,Vbscript,Outlook,我想获取来自特定发件人的未读邮件的电子邮件地址。我尝试了以下代码,但无效 Set olApp=CreateObject("Outlook.Application") Set olMAPI=olApp.GetNameSpace("MAPI") Set oFolder = olMAPI.GetDefaultFolder(6) Set allEmails = oFolder.Items For Each email In oFolder.Items If email.Unread = True

我想获取来自特定发件人的未读邮件的电子邮件地址。我尝试了以下代码,但无效

Set olApp=CreateObject("Outlook.Application")
Set olMAPI=olApp.GetNameSpace("MAPI") 
Set oFolder = olMAPI.GetDefaultFolder(6)
Set allEmails = oFolder.Items

For Each email In oFolder.Items


If email.Unread = True Then
If email.SenderEmailAddress="Kalyanam.Raghuram@xxxx.com" Then

MsgBox email.Subject


End If
End If
Next
所以我检查了“email.SenderEmailAddress”实际上是用什么验证的,然后插入了这个代码

For Each email In oFolder.Items

If email.Unread = True Then

MsgBox email.Subject
MsgBox email.SenderEmailAddress


End If
Next

它给了我一些无法理解但可读的输出。请告诉我任何解决方案。

您发布的代码对我有效,我使用的是Windows Vista和Outlook 2007

我想改变的一件事是

If LCase(email.SenderEmailAddress) = LCase("Kalyanam.Raghuram@xxxx.com") Then wscript.echo email.Subject End If 如果LCase(email.SenderEmailAddress)=LCase(“Kalyanam。Raghuram@xxxx.com)那么 wscript.echo email.Subject 如果结束
你是说你得到了一个EX类型的地址而不是预期的SMTP地址

你看过交换者的主要地址了吗? 在您的情况下,可以使用MailItem.Sender.GetExchangeUser.PrimarySmtpAddress。准备好处理空值,因为每个值都可以为空。

谢谢:)你是对的,它是EX类型的地址。你的解决方案对我有效。