Getting Started - Reading attachment

Status
Not open for further replies.
D

Diane

Group,

As our company sends emails, we get a volume of returns with errors such as

mailbox full, no such user, no mailbox by that name, etc...... Some of these

messages includes an attachment "details.txt" which specifically list a

STATUS and Final-Recipient. I am looking for a getting started guide that

will help me read the attachment and pull out the status and the

"Final-Recipient. From this, I can update our email database. Any "getting

started" guides would be appreciated.

Diane
 
Outlook version?

How would you intend to code this, as an Outlook macro in VBA code, or what?

Are you an Outlook code beginner or a code beginner?

A wealth of information is at www.outlookcode.com. There's a code sample

that strips all attachments from selected emails after saving them to a temp

folder on my Web site at

http://www.slovaktech.com/code_samples.htm#StripAttachments. If you use that

code in an Outlook macro you'd just substitute the use of Application for

getting the Outlook.Application object. Outside of Outlook you'd use the

code as is.

To get the information from a text attachment you need to save it to the

file system and open it. A text file can just be opened and parsed as

strings. You can split the contents of a text file into a string array on

newlines and inspect each line to see if has any tag value you want to

parse.

"Diane" <Diane> wrote in message

news:A26E63D9-415F-4B4B-9E03-0A7F463CC2C8@microsoft.com...
> Group,
> As our company sends emails, we get a volume of returns with errors such
> as
> mailbox full, no such user, no mailbox by that name, etc...... Some of
> these
> messages includes an attachment "details.txt" which specifically list a
> STATUS and Final-Recipient. I am looking for a getting started guide that
> will help me read the attachment and pull out the status and the
> "Final-Recipient. From this, I can update our email database. Any
> "getting
> started" guides would be appreciated.
> Diane
 
Ken,

I'm very familiar with VBA, this is the route that I intend to take.

I've done many VBA projects in Word and some in Excel, but none with

Outlook.

I have subfolders that mail filters into within my inbox, from these

subfolders, I would like to create a program that can

1) read the header, (or the attached "details.txt" file), find the error

status,

and

2) for any invalid emails, mailbox fulls, etc....., run an sql delete

statement that will remove invalid emails from a database.

I'm good with doing step 2, it's just getting me started on step #1. I have

noticed for any "Mail Delivery" failures, that is where I find the attached

"details.txt" file. This file has the status code and the Final-Recipient

info that I would like to work with in step 1 of my VBA code.

Anyway, I believe VBA is the way that I want to go with this, if you have

other advice for this situation, I'm interested.

Thanks,

Diane
wrote:


> Outlook version?

> How would you intend to code this, as an Outlook macro in VBA code, or what?

> Are you an Outlook code beginner or a code beginner?

> A wealth of information is at www.outlookcode.com. There's a code sample
> that strips all attachments from selected emails after saving them to a temp
> folder on my Web site at
> http://www.slovaktech.com/code_samples.htm#StripAttachments. If you use that
> code in an Outlook macro you'd just substitute the use of Application for
> getting the Outlook.Application object. Outside of Outlook you'd use the
> code as is.

> To get the information from a text attachment you need to save it to the
> file system and open it. A text file can just be opened and parsed as
> strings. You can split the contents of a text file into a string array on
> newlines and inspect each line to see if has any tag value you want to
> parse.

> >

>

> "Diane" <Diane> wrote in message
> news:A26E63D9-415F-4B4B-9E03-0A7F463CC2C8@microsoft.com...
> > Group,
> > As our company sends emails, we get a volume of returns with errors such
> > as
> > mailbox full, no such user, no mailbox by that name, etc...... Some of
> > these
> > messages includes an attachment "details.txt" which specifically list a
> > STATUS and Final-Recipient. I am looking for a getting started guide that
> > will help me read the attachment and pull out the status and the
> > "Final-Recipient. From this, I can update our email database. Any
> > "getting
> > started" guides would be appreciated.
> > Diane


>
 
VBA is fine for that. The main limitation for VBA code is it's not designed

for deployment to other users, and it can't handle Outlook 2007 or 2010

Ribbon or FormRegion callbacks. Other than that it shouldn't be any problem.

The link I provided has code you can modify to strip the attachments on the

selected items and save them to temp folders. From there you should be able

to do your parsing easily if you are familiar with VBA. I used

FileSystemObject for the file processing which should be OK, and if desired

you can just remove the lines that delete the saved attachments so they

remain on the original items.

For not using only selected items but for iterating the contents of a folder

looking for items with a "details.txt" attachment you can use a procedure

that gets passed the folder and does something like this:

Dim colItems As Outlook.Items

Dim obj As Object

Dim oMail As Outlook.MailItem

Dim colAttach As Outlook.Attachments

Dim oAttach As Outlook.Attachment

Set colItems = folder.Items

For Each obj In colItems

If obj.Class = olMail then

Set oMail = obj

Set colAttach = oMail.Attachments

If colAttach.Count > 0 Then

For Each oAttach In colAttach

If oAttach.DisplayName = "details.txt" Then

' process this item

And so on.

Searching at www.outlookcode.com for specific things such as "iterating

Outlook folders" should get you samples of the other pieces you need.

"Diane" <Diane> wrote in message

news:ED668632-0761-4E55-B731-301D0E2F9868@microsoft.com...
> Ken,
> I'm very familiar with VBA, this is the route that I intend to take.
> I've done many VBA projects in Word and some in Excel, but none with
> Outlook.

> I have subfolders that mail filters into within my inbox, from these
> subfolders, I would like to create a program that can

> 1) read the header, (or the attached "details.txt" file), find the error
> status,
> and
> 2) for any invalid emails, mailbox fulls, etc....., run an sql delete
> statement that will remove invalid emails from a database.

> I'm good with doing step 2, it's just getting me started on step #1. I
> have
> noticed for any "Mail Delivery" failures, that is where I find the
> attached
> "details.txt" file. This file has the status code and the Final-Recipient
> info that I would like to work with in step 1 of my VBA code.

> Anyway, I believe VBA is the way that I want to go with this, if you have
> other advice for this situation, I'm interested.

> Thanks,
> Diane
 
Ken,

I finally had a chance to work with your examples and found the "Strip All

Attachments From Selected Email Items" worked instantly. I understand what

is happening here, now I need to modify so that I can iterate through the

folder and not just on a selected item. I have done something similar to

this in MS WORD and with your example below, I should be good to go.

Many Thanks for getting me started!!

Diane
wrote:


> VBA is fine for that. The main limitation for VBA code is it's not designed
> for deployment to other users, and it can't handle Outlook 2007 or 2010
> Ribbon or FormRegion callbacks. Other than that it shouldn't be any problem.

> The link I provided has code you can modify to strip the attachments on the
> selected items and save them to temp folders. From there you should be able
> to do your parsing easily if you are familiar with VBA. I used
> FileSystemObject for the file processing which should be OK, and if desired
> you can just remove the lines that delete the saved attachments so they
> remain on the original items.

> For not using only selected items but for iterating the contents of a folder
> looking for items with a "details.txt" attachment you can use a procedure
> that gets passed the folder and does something like this:

> Dim colItems As Outlook.Items
> Dim obj As Object
> Dim oMail As Outlook.MailItem
> Dim colAttach As Outlook.Attachments
> Dim oAttach As Outlook.Attachment

> Set colItems = folder.Items
> For Each obj In colItems
> If obj.Class = olMail then
> Set oMail = obj
> Set colAttach = oMail.Attachments
> If colAttach.Count > 0 Then
> For Each oAttach In colAttach
> If oAttach.DisplayName = "details.txt" Then
> ' process this item

> And so on.

> Searching at www.outlookcode.com for specific things such as "iterating
> Outlook folders" should get you samples of the other pieces you need.

> >

>

> "Diane" <Diane> wrote in message
> news:ED668632-0761-4E55-B731-301D0E2F9868@microsoft.com...
> > Ken,
> > I'm very familiar with VBA, this is the route that I intend to take.
> > I've done many VBA projects in Word and some in Excel, but none with
> > Outlook.
> > I have subfolders that mail filters into within my inbox, from these
> > subfolders, I would like to create a program that can
> > 1) read the header, (or the attached "details.txt" file), find the error
> > status,
> > and
> > 2) for any invalid emails, mailbox fulls, etc....., run an sql delete
> > statement that will remove invalid emails from a database.
> > I'm good with doing step 2, it's just getting me started on step #1. I
> > have
> > noticed for any "Mail Delivery" failures, that is where I find the
> > attached
> > "details.txt" file. This file has the status code and the Final-Recipient
> > info that I would like to work with in step 1 of my VBA code.
> > Anyway, I believe VBA is the way that I want to go with this, if you have
> > other advice for this situation, I'm interested.
> > Thanks,
> > Diane


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Help Getting Started? BCM (Business Contact Manager) 4
L Getting Index from dropdown inserted on ribbon Outlook VBA and Custom Forms 3
e_a_g_l_e_p_i Question about installing my Gmail account on my iPhone but still getting messages downloaded to my desktop Outlook. Using Outlook 3
P now on office 365 but getting error messages about missing Outlook 2013 cache folders Using Outlook 2
W Outlook 365 I am getting the "Either there is no default mail client" error when I try to send an email on excel Office 365 Using Outlook 1
H Outlook 365 issue getting details from embedded files, crashing routine Outlook VBA and Custom Forms 0
A Links in email getting error message about group policy Using Outlook 4
Commodore Getting rid of "This computer only" Using Outlook 4
V Outlook 2016 Multiple recurring tasks getting created Using Outlook 0
P PST file is getting huge under POP 3 Using Outlook 2
N contact notepad 'style' getting changed after clicking and running Activities Using Outlook 2
S Outlook [Online - Office365] perfomance is getting affected when accessing the mails using Redemptio Using Outlook 1
D Close Oulook after sending emails via vba without outbox getting stuck. Outlook VBA and Custom Forms 1
C im getting a type mismatch error Outlook VBA and Custom Forms 3
William getting custom form to load category colors Outlook VBA and Custom Forms 4
C Getting back previous computer owner Outlook email Using Outlook.com accounts in Outlook 1
B Recipient of a forwared message getting multiple emails Using Outlook 2
S Outlook 2010 I am getting error code 0x8DE00006 'the operation failed'. outlook 2010 send/receive progress Using Outlook.com accounts in Outlook 2
S Mails getting downloaded multiple times Using Outlook 1
Rory Campion Not getting a warning when a shared calendar item has been updated by someone else Using Outlook 2
E Getting IMAP email into existing pst file Using Outlook 6
J Just installed Outlook 2010 on computer and user is getting a 0x80004005 error Using Outlook.com accounts in Outlook 1
R Getting a colleagues appointments and calendar entries Using Outlook 1
E Getting Outlook full name correct with AddressLayout Using Outlook 1
P I'm getting an error when opening Outlook "Mobile me stopped working Using Outlook 1
D Need Help with Script. Keep getting Runtime Error 438 BCM (Business Contact Manager) 4
R Need help getting BCM to work with my Outlook 2014 Using Outlook 4
P I am getting an error msg = cannot open file access denied Using Outlook 3
K why is a user getting email respond for invite respond that she didn't set up. Using Outlook 3
B email getting cut off Using Outlook 9
L Need help getting calendar/contacts/tasks/notes back! Using Outlook 3
M Email Format getting changed to Plain Text Using Outlook 1
G Outlook 2013: Getting meeting invites in OWA format Using Outlook 9
M Getting messages from multiple email address Using Outlook 1
B not getting email from people Using Outlook 3
L Outlook 2010 - Keep getting "Corrupted File" Msgs Using Outlook 4
mrje1 Assigned Categories keep getting deleted in mail, bug? How to fix if possible? Using Outlook 5
Commodore Why some RSS feeds stop getting updates? Using Outlook 12
M All e mails seem to be getting blocked BCM (Business Contact Manager) 7
J Send/receive getting stuck Using Outlook.com accounts in Outlook 1
R Getting my Claendar additions to appear in Outlook Today Using Outlook 7
J Getting Contact Name to show on Calendar Using Outlook 2
D outlook getting stuck receiving Using Outlook 1
Y MICROSOFT OUTLOOK 2007 - i KEEP GETTING THE "ENTER NETWORK PASSWORD" BOX POPPING UP - IT IS ALREADY Using Outlook 4
T getting an error This file does not have a program associated with it for performing this action. C Using Outlook 7
C getting the subject line out of a mail Outlook VBA and Custom Forms 2
S Trying to install BCM 2010 x64, getting error BCM (Business Contact Manager) 8
Q I cannot start Outlook 2007 I keep getting this error: __'Cannot start outlook window. Invalid XML,the view cannot be loaded.' Using Outlook 3
N Getting the attachments in MailItem Outlook VBA and Custom Forms 1
K Getting (internal) sender's account ID (userID) Outlook VBA and Custom Forms 2

Similar threads

Back
Top