Undelivered emails

rwhjg

New Member
Hi, I am trying to get any emails that come back undelivered. I had been using Get Received Items (Basic) from the MS Outlook Email VBO. It will pick up any emails in the inbox and put them in a collection but it will ignore any emails that came back Undelivered. Does anybody know how I can get these undelivered emails? Thanks
 

Javier

New Member
Hi, I am trying to get any emails that come back undelivered. I had been using Get Received Items (Basic) from the MS Outlook Email VBO. It will pick up any emails in the inbox and put them in a collection but it will ignore any emails that came back Undelivered. Does anybody know how I can get these undelivered emails? Thanks




I have the same issue. Anyone solved it?

Thanks
Javier.
 

to_mas_re

New Member
Hi all!

I had a similar problem and I've found that undelivered e-mails are of a different object than regular e-mail. In code stage of action "Internal_Get Items" you can find this line:
Code:
If Not TypeOf item Is MailItem Then Continue For
.

Regular e-mails are MailItem objects but undeliverable e-mails are ReportItem objects. So you have to change this line of code. And since ReportItem has different properties, you will not find SenderName etc. and you will have to change these lines too (and output collection of course).

You can find ReportItem properties here https://docs.microsoft.com/en-us/office/vba/api/outlook.reportitem

I duplicated the original action and created new for all the other types of e-mail (I believe there are only two types, but I can be wrong here). Here is my code:

Code:
.
.
.

Dim dataTable As New Data.DataTable
dataTable.Columns.Add("EntryID", Type.GetType("System.String"))
dataTable.Columns.Add("Subject", Type.GetType("System.String"))
dataTable.Columns.Add("Body", Type.GetType("System.String"))
dataTable.Columns.Add("CreationTime", Type.GetType("System.DateTime"))
dataTable.Columns.Add("Unread", Type.GetType("System.Boolean"))

Dim folderItems = If(Filter_Expression <> "", folder.Items.Restrict(Filter_Expression), folder.Items)

For Each item As Object In folderItems
    If TypeOf item Is MailItem Then Continue For
    Dim row As Data.DataRow = dataTable.NewRow
    row("EntryID") = item.EntryID
    row("Subject") = item.Subject
    row("Body") = item.Body
    row("CreationTime") = item.CreationTime
    row("Unread") = item.Unread
    dataTable.Rows.Add(row)
    Item_Count += 1
Next
Items = dataTable
 

hazem

New Member
Hi all!

I had a similar problem and I've found that undelivered e-mails are of a different object than regular e-mail. In code stage of action "Internal_Get Items" you can find this line:
Code:
If Not TypeOf item Is MailItem Then Continue For
.

Regular e-mails are MailItem objects but undeliverable e-mails are ReportItem objects. So you have to change this line of code. And since ReportItem has different properties, you will not find SenderName etc. and you will have to change these lines too (and output collection of course).

You can find ReportItem properties here https://docs.microsoft.com/en-us/office/vba/api/outlook.reportitem

I duplicated the original action and created new for all the other types of e-mail (I believe there are only two types, but I can be wrong here). Here is my code:

Code:
.
.
.

Dim dataTable As New Data.DataTable
dataTable.Columns.Add("EntryID", Type.GetType("System.String"))
dataTable.Columns.Add("Subject", Type.GetType("System.String"))
dataTable.Columns.Add("Body", Type.GetType("System.String"))
dataTable.Columns.Add("CreationTime", Type.GetType("System.DateTime"))
dataTable.Columns.Add("Unread", Type.GetType("System.Boolean"))

Dim folderItems = If(Filter_Expression <> "", folder.Items.Restrict(Filter_Expression), folder.Items)

For Each item As Object In folderItems
    If TypeOf item Is MailItem Then Continue For
    Dim row As Data.DataRow = dataTable.NewRow
    row("EntryID") = item.EntryID
    row("Subject") = item.Subject
    row("Body") = item.Body
    row("CreationTime") = item.CreationTime
    row("Unread") = item.Unread
    dataTable.Rows.Add(row)
    Item_Count += 1
Next
Items = dataTable


Hello this is working but the body is always in chinese! do you have any idea why ?
 

to_mas_re

New Member
Hello this is working but the body is always in chinese! do you have any idea why ?
I do not. I also see the body in Chinese, but I do not work with the body since there is no valuable information for me. If you find out the solution, I'd be glad to hear about it ;)
 

sck360

New Member
Hi Guys,

Does anyone have a solution to these emails coming back in Chinese?

Setting to UTF8 doesn't appear to be working

Thanks
Shane
 
Top