?
Solved

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

Posted on 2010-09-06
4
Medium Priority
?
379 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 2000 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 93

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

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.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
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: …

719 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