03-01-2019, 02:51 PM
Hi All,
I've been trying to simply display the body email of an email message in a message box (code below), but consistently get a general run error and I don't know where i've been wrong. I've even attempted to save the email but get them 'General Run Error'. Any help would be appreciated! Thanks!
Using UFT version 14.51
Set OutlookApp = CreateObject("Outlook.Application")
Set myNamespace = OutlookApp.GetNameSpace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(6)
myFolder.Display
Set colItems = myFolder.Items
Set colFilteredItems = colItems.Restrict("[SenderEmailAddress] = 'no-reply@verificationemail.com'")
For each item in colFilteredItems
If item.Unread Then
If InStr(item.Subject, "SKF Insight Rail") > 0 Then
'item.SaveAs "C:\Email Data\Text.txt", 0
myBody = item.body
item.unread = false
End If
End If
Next
msgbox myBody
I've been trying to simply display the body email of an email message in a message box (code below), but consistently get a general run error and I don't know where i've been wrong. I've even attempted to save the email but get them 'General Run Error'. Any help would be appreciated! Thanks!
Using UFT version 14.51
Set OutlookApp = CreateObject("Outlook.Application")
Set myNamespace = OutlookApp.GetNameSpace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(6)
myFolder.Display
Set colItems = myFolder.Items
Set colFilteredItems = colItems.Restrict("[SenderEmailAddress] = 'no-reply@verificationemail.com'")
For each item in colFilteredItems
If item.Unread Then
If InStr(item.Subject, "SKF Insight Rail") > 0 Then
'item.SaveAs "C:\Email Data\Text.txt", 0
myBody = item.body
item.unread = false
End If
End If
Next
msgbox myBody