Solved

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

Posted on 2010-09-06
4
369 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Resolve DNS query failed errors for Exchange
Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

21 Experts available now in Live!

Get 1:1 Help Now