sarya
14 years agoFrequent Contributor
How to verify if an outlook e-mail is received
Hi,
I am trying to write a code where I need to verify if the outlook e-mail has been received with specific body contents. I saw one script in the 'How To' section that checks if an e-mail is received but that is too complicated. Is there some easy way to put together if the e-mail with specific body contents is received in a folder ? I have this code below that checks the subject and body of the e-mail but problem is that sometimes I need to verify if an e-mail is actually received or not in the folder even when folder is empty but the code below works when there is atleast one e-mail in the folder. So my verification is if there is a specific mail received or not even if the folder is empty .
Thanks,
Sumedha
I am trying to write a code where I need to verify if the outlook e-mail has been received with specific body contents. I saw one script in the 'How To' section that checks if an e-mail is received but that is too complicated. Is there some easy way to put together if the e-mail with specific body contents is received in a folder ? I have this code below that checks the subject and body of the e-mail but problem is that sometimes I need to verify if an e-mail is actually received or not in the folder even when folder is empty but the code below works when there is atleast one e-mail in the folder. So my verification is if there is a specific mail received or not even if the folder is empty .
var msOutlook = Sys.OleObject("Outlook.Application");
var mapi = msOutlook.GetNamespace("MAPI");
var inbox = mapi.Folders("Mailbox - Sumedha Arya").Folders("Inbox").Folders("Test");
for( i = 0; i <= inbox.Items.Count; i++)
{
toolEmail = inbox.Items.Item(i);
sub1 = toolEmail.Body;
sub2 = toolEmail.Subject;
Log.Message(toolEmail.Body + "And " + toolEmail.Subject);
if (sub1.indexOf(body1)!= -1 && sub1.indexOf(body2)!= -1 && sub2.indexOf(sub)!=-1)
{
Log.Message("The body and subject of the mail are verified","",pmNormal,Attr);
}
else
{
Log.Error("There is some error","",pmNormal,Attr);
}
Thanks,
Sumedha