Solved

Get email address of original receipient(s) out of a returned non deliverable email reply.

Posted on 2010-09-06
4
370 Views
Last Modified: 2013-11-27
Hi Experts,
I'm regularily I'm sending out hundreds of email via mailmerge with Winword. Many emails addresses are invalid and therefore I receive hundreds replies (e.g. "Undelievered Mail Return", "Message delivery notice","Delivery FAilure",...).
Currently I'm archiving all this received NDR within an Outlook folder, and have this Outlook folder linked the folder within MSAccess2007 so that I can access them and retrieve info via MAPI calls. However I cannot get the origianl receipients email address. In order to clean up my customer database by removing the invalid email addresses I'm looking for:

MSAccess VBA code which programmatically goes through all emails in the linked outlook folder and writes the original senders email address (where mail could not be delivered) into a MSAccess table.

Thanks in advace for your help-
Martin
0
Comment
Question by:MartinNeubauer
4 Comments
 
LVL 6

Accepted Solution

by:
OxonDev earned 500 total points
ID: 33612598
Hi Martin,

If you want to loop through a folders mail items you can use this:

Public Sub LoopEMail()
'Needs reference to C:\Program Files\Microsoft Office\Office12\MSOUTL.OLB or similar
On Error GoTo Err_LoopEMail

Dim objNamespace As Namespace
Dim objInboxFolder As MAPIFolder
Dim objMailItem As MailItem
Dim objSubFolder As MAPIFolder

    Set objNamespace = GetNamespace("MAPI")
    Set objInboxFolder = objNamespace.GetDefaultFolder(olFolderInbox)
   
    If objInboxFolder.Items.Count = 0 Then GoTo Exit_LoopEMail

    For Each objMailItem In objInboxFolder.Items
        Debug.Print objMailItem.Subject
    Next objMailItem

Exit_LoopEMail:
    Exit Sub

Err_LoopEMail:
    MsgBox "LoopEMail Error " & Err.Number & ": " & Err.Description
    Resume Exit_LoopEMail
End Sub

There's further info in thsi article for navigating  specific folders:  http://www.outlookcode.com/d/code/getfolder.htm

However, that'll only get you half way as the recipients list of each mail item will be you...  I'd suggest you grab the body text & compare it with your contacts list.  Usually the body will contain a reference to unable to deliver to InvalidAddress@Unknown.com

However, this would only work if you sent to one address at a time as some include successful addresses as well.
0
 

Author Comment

by:MartinNeubauer
ID: 33615246
Hi OxonDev,

thanks, yes this helps me to access mail by mail. I thought to parse somehow the content for email as you mentioned, but the content in those mails look very different.
Note: Yes, I only send to one receipient at a time.
Well Step 1 (accessing mail individually) done :-)

I remember somebody said that somehwere within a mail (header?) additional info (like mail receipients history, transporting mailservers, etc should be available. Hopefully that's true and  we can retrieve this.
Any other ideas to get Step 2 (mailhistory, original receipients)

Thanks,
Martin
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34118953
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now