Solved

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

Posted on 2010-09-06
4
376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

631 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