A user is sending out a mass mailing through Outlook via Access automation. Many of these email addresses are obsolete and the email will bounce back to Outlook as "undeliverable." The user wants to update his list of email addresses in the application so that he avoids the invalid email addresses for future mailings. Is there any way to get a list of the bounced email addresses from Outlook into Access? The user can put all the bounced emails in a folder, if that helps.
5 9045
The following Code will at least give you a listing of all E-Mails that were not deliverable. Other information should be easily extracted by using the Properties of the Outlook Item Object. -
Dim outOutlook As New Outlook.Application
-
Dim outNamespace As Outlook.NameSpace
-
Dim myInbox As Outlook.MAPIFolder
-
'Dim myDestFolder As Outlook.MAPIFolder
-
Dim outItems As Outlook.Items
-
Dim outItem As Object
-
'Dim strFolderName As String
-
-
-
Set outNamespace = outOutlook.GetNamespace("MAPI")
-
Set myInbox = outNamespace.GetDefaultFolder(olFolderInbox)
-
-
Set outItems = myInbox.Items
-
-
DoCmd.Hourglass True
-
-
'Retrieve the Undeliverable E-Mail Subjects
-
For Each outItem In outItems
-
If InStr(outItem.Subject, "Delivery Status Notification (Failure)") > 0 Then
-
Debug.Print outItem.Subject
-
End If
-
Next
-
-
DoCmd.Hourglass False
-
-
Set outOutlook = Nothing
-
Set outNamespace = Nothing
-
Set outItem = Nothing
ADezii, thanks a megabyte. I guess I would use something like outItem.EmailAddress to get the email out of it. Thanks again.
I am not sure if EMailAddress will work in this context, but if it doesn't, the following Logic should provide an easy solution: - Search every E-Mail in the Inbox analyzing its Subject to determine if it was Undeliverable. In my Code example the Search Text Delivery Status Notification (Failure) worked.
- For each Undeliverable, extract the E-Mail Address from the Body of the E-Mail. From what I have seen it will be enclosed within the first occurrence of '<' and a closing '>'.
- I would actually write these Undeliverable E-Mail Addresses to a Local table where they would be easily accessible.
- Do whatever you feel is best and let us know how you make out.
- Partial Code example follows:
-
'****************************** CODE INTENTIONALLY OMITTED ******************************
-
Dim intFirst As Integer 'Location of first '<'
-
Dim intLast As Integer 'Location of first '>' after '<'
-
Dim strBody As String 'Will hold Body Text of Undeliverable E-Mail
-
Dim strUndlvr 'Holds the actual Undeliverable E-Mail Address
-
-
intFirst = InStr(s, "<")
-
intLast = InStr(intFirst + 1, s, ">")
-
-
For Each outItem In outItems 'All Items in the Inbox
-
If InStr(outItem.Subject, "Delivery Status Notification (Failure)") > 0 Then
-
strBody = outItem.Body 'Body of Undeliverable E-Mail
-
strUndlvr = Mid$(s, (intFirst + 1), (intLast - intFirst) - 1) 'E-Mail Address
-
End If
-
Next
-
'****************************** CODE INTENTIONALLY OMITTED ******************************
-
ADezii, what is the variable "s" in your code sample? I don't see it declared and am not sure where its value is determined. Thanks for the help.
My sincere apologies. The Variable s was simply used to simulate Text in the Body of each Undeliverable E-Mail, and to make sure that the Address Extraction Code worked as intended. I am currently at home and do not have Outlook installed and I needed a method to simulate what a typical Body Text may consist of. The proper approach would be: - '****************************** CODE INTENTIONALLY OMITTED ******************************
-
Dim intFirst As Integer 'Location of first '<'
-
Dim intLast As Integer 'Location of first '>' after '<'
-
Dim strBody As String 'Will hold Body Text of Undeliverable E-Mail
-
Dim strUndlvr 'Holds the actual Undeliverable E-Mail Address
-
-
For Each outItem In outItems 'All Items in the Inbox
-
If InStr(outItem.Subject, "Delivery Status Notification (Failure)") > 0 Then
-
strBody = outItem.Body 'Body of Undeliverable E-Mail
-
intFirst = InStr(strBody, "<")
-
intLast = InStr(intFirst + 1, strBody, ">")
-
strUndlvr = Mid$(strBody, (intFirst + 1), (intLast - intFirst) - 1) 'E-Mail Address
-
End If
-
Next
-
'****************************** CODE INTENTIONALLY OMITTED ******************************
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Christine Forber |
last post by:
I wonder if anyone knows of some javascript code to check a
comma-delimited list of email addresses for basic formating.
What I'm looking for is the javascript code to check a form field on
form...
|
by: Bob |
last post by:
Hi Everybody
I have an MS Access Database that accesses the MS Outlook Inbox.
I want to be able to see the full email address that the communication
has come from while within Ms Access.
...
|
by: scott_baird |
last post by:
I have an email macro setup (maybe I should go another way, but that
was the quickest at the moment...) and what I would like to do is
automate the "to" addressee of the email it generates for...
|
by: brbxx99x |
last post by:
Hi, I'm just wondering how I can display the outlook address list (the screen that is displayed when one clicks on either the TO, CC or BCC buttons) and retrieve the email addresses that the user...
|
by: Nick Bell |
last post by:
The expression:
preg_match_all("/text.*?(+@+\.{2,6})/i",$f,
$matches);
Returns ONE email address on a line in $f beginning 'text' - how do I
retrieve ALL the email addresses on a line in $f...
|
by: Frank |
last post by:
Hello All,
I am exploring and developing a plan for a C# web app or windows app to
handle bounced emails.
Basically, I need to develop a system where I weed out bad addresses in our
db...but...
|
by: dreamsoul620 via AccessMonster.com |
last post by:
Hi all! I'm trying to set up an email application for my database. I tried
linking to my Outlook address book, but when reading from the table, I
receive an error message saying I need to restart...
|
by: muddasirmunir |
last post by:
i want list of e-mail address from different countries
so can any body guide me how to achive this task .
is there any website/utility from which we can extract mail address
for e-g
i want mail...
|
by: Dennis |
last post by:
Hi, I have a text file that contents a list of email addresses like
this:
"foo@yahoo.com"
"tom@hotmail.com"
"jerry@gmail.com"
"tommy@apple.com"
I like to
|
by: Sergeles |
last post by:
I am currently in the process of making/maintaining a database for a school club. I started the database mostly from scratch and i have a pretty good familiarity with Access (been using it for almost...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |