Iterate through collection of attachments

Status
Not open for further replies.
P

PromisedOyster

In my Outlook.Attachment collection I want to be able to distinguish

between real attachments as opposed to images that have been embedded

in the message body. However, in the attachment collection of objects,

I am not sure how I can do this as they are all just treated as

attachments and there is no distinguishing feature that I acn see to

tell them apart. File type will not suffice I dont think?

Outlook.MailItem mi = (get MSG file from database);

// Iterate through the attachments

foreach (Outlook.Attachment att in mi.Attachments)

{

// I only want to save real attachments, eg if (att.RealAttachment)

att.SaveAsFile(attFile);

}
 
Outlook version? If you are using Outlook 2007 you can use the

PropertyAccessor of the Attachment object to check for PR_ATTACH_CONTENT_ID,

which is only there as a property for embedded attachments. That has a DASL

property tag of "http://schemas.microsoft.com/mapi/proptag/0x3712001E" or

"urn:schemas:mailheader:content-id".

If you aren't using Outlook 2007 you'd need to use an alternate API such as

Redemption (www.dimastr.com/redemption) to get at that property. CDO 1.21 or

Extended MAPI aren't options for managed code.

"PromisedOyster" <PromisedOyster@hotmail.com> wrote in message

news:16c17346-d163-4ddc-b332-1dca54ba9507@l30g2000yqb.googlegroups.com...
> In my Outlook.Attachment collection I want to be able to distinguish
> between real attachments as opposed to images that have been embedded
> in the message body. However, in the attachment collection of objects,
> I am not sure how I can do this as they are all just treated as
> attachments and there is no distinguishing feature that I acn see to
> tell them apart. File type will not suffice I dont think?

> Outlook.MailItem mi = (get MSG file from database);

> // Iterate through the attachments
> foreach (Outlook.Attachment att in mi.Attachments)
> {
> // I only want to save real attachments, eg if (att.RealAttachment)
> att.SaveAsFile(attFile);
> }
 
Keep in midn tha tsome attachments have PR_ATTACH_LOCATION.

Some other attachment have nothign but a regular fiel

name(PR_ATTACH_LONG_FILENAME), but are still hidden. You' really need to

parse the HTML body to see if it refers to the attachments.

Also note that Redemption exposes RDOAttachment.Hidden property that takes

all of that into account.

Dmitry Streblechenko (MVP)

-
<kenslovak@mvps.org> wrote in message

news:u3lqwyemKHA.5840@TK2MSFTNGP05.phx.gbl...
> Outlook version? If you are using Outlook 2007 you can use the
> PropertyAccessor of the Attachment object to check for
> PR_ATTACH_CONTENT_ID, which is only there as a property for embedded
> attachments. That has a DASL property tag of
> "http://schemas.microsoft.com/mapi/proptag/0x3712001E" or
> "urn:schemas:mailheader:content-id".

> If you aren't using Outlook 2007 you'd need to use an alternate API such
> as Redemption (www.dimastr.com/redemption) to get at that property. CDO
> 1.21 or Extended MAPI aren't options for managed code.

> >

>

> "PromisedOyster" <PromisedOyster@hotmail.com> wrote in message
> news:16c17346-d163-4ddc-b332-1dca54ba9507@l30g2000yqb.googlegroups.com...
> > In my Outlook.Attachment collection I want to be able to distinguish
> > between real attachments as opposed to images that have been embedded
> > in the message body. However, in the attachment collection of objects,
> > I am not sure how I can do this as they are all just treated as
> > attachments and there is no distinguishing feature that I acn see to
> > tell them apart. File type will not suffice I dont think?
>

>> Outlook.MailItem mi = (get MSG file from database);
>

>> // Iterate through the attachments
> > foreach (Outlook.Attachment att in mi.Attachments)
> > {
> > // I only want to save real attachments, eg if (att.RealAttachment)
> > att.SaveAsFile(attFile);
> > }

>
 
True, those other properties are sometimes there for embedded attachments. A

complete test would look at all of them or use the RDO property. Most of the

time I've seen only PR_ATTACH_CONTENT_ID however.

"Dmitry Streblechenko" <dmitry@dimastr.com> wrote in message

news:%23$hLxSgmKHA.5520@TK2MSFTNGP06.phx.gbl...
> Keep in midn tha tsome attachments have PR_ATTACH_LOCATION.
> Some other attachment have nothign but a regular fiel
> name(PR_ATTACH_LONG_FILENAME), but are still hidden. You' really need to
> parse the HTML body to see if it refers to the attachments.
> Also note that Redemption exposes RDOAttachment.Hidden property that takes
> all of that into account.

> > Dmitry Streblechenko (MVP)
>

>

>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Deleted Items - Unable to Iterate All of Items Outlook VBA and Custom Forms 1
A How to create fixed signatures for aliases that process through GMAIL? Outlook VBA and Custom Forms 0
S Macro for Loop through outlook unread emails Outlook VBA and Custom Forms 2
Y Images coming through as Cid:image in outlook Using Outlook 0
Jennifer Murphy Ctrl+Tab sometimes will not move through text a word at a time Using Outlook 1
Rupert Dragwater Scrolling through Directories hesitates Using Outlook 1
N Outlook Email Rule execution through shortcut keys (VBA codes) Using Outlook 1
A Outlook - Send New 20 Attachments through Email Using Outlook 4
A Outlook incompleted tasks has strike through Using Outlook 3
H Custom autoforwarding, sending mail through outlook office 365 Using Outlook 1
A Sending Emails Through Outlook From Multiple Email Addresses Using Outlook 1
T Can't send email through connected account (outlook.live.com) - goes to Drafts folder Using Outlook.com accounts in Outlook 3
Tim King Send mail from MSWord through Outlook Using Outlook 3
P Threat to being a spammer while sending automatic Emails through VBA Using Outlook 3
S Ask user to input email template through VBA Outlook VBA and Custom Forms 1
2 Task has a strike through but is not complete - how to remove? Using Outlook 1
Stefanos Update Sharepoint tasks through Outlook Using Outlook 2
L Outlook 2007 Search Through E-Mail Using Outlook 41
R Outlook Cache Mode Terminalserver disable through Registry Using Outlook 1
T Synchronize outlook appointments through web application. Using Outlook 1
L Cannot send emails through @live.co.uk account in outlook 2013 Using Outlook 0
L Cannot send emails through @live.co.uk account in outlook 2013 Using Outlook 2
C Insert date in Subject through date picker Using Outlook 0
S Send if approved (through email) Using Outlook 1
M syning multiple calendars from Outlook 2007 through iTunes Using Outlook 3
J Using Outlook through BlackBerry Z10 Using Outlook 4
I Outlook 2003 won't send emails through one router, but will through another Using Outlook 1
K Clearing/Deleting all Public Folders through VBA Using Outlook 3
L Reminder default time not going through Using Outlook 7
S Tasks are handled through email but deleted email removes task history? Exchange Server Administration 3
D Line through message instead of sending to Delete folder??? Using Outlook 3
D Outlook Contact Notes show previous history with strike through. Using Outlook 1
I Send Secure Email Through Microsoft Outlook 2007 and 2010 (32 bit) Using Outlook 0
I Send Secure Email Through Microsoft Outlook 2007 and 2010 (32 bit) Using Outlook 0
A Are Public Folders Contacts available through activesync for Windows Phone 7, Iphone, etc? Exchange Server Administration 3
R Multiple Domains routing through multiple send connectors Exchange Server Administration 5
J Create or Import a Outlook Rule through C# code. Outlook VBA and Custom Forms 2
R Access Program Only Looping Part Way Through Outlook Inbox Outlook VBA and Custom Forms 2
K loop through distribution group (and potentially, embedded DGs) by Outlook VBA and Custom Forms 1
C OL Sub through or by Excel Macro Call Outlook VBA and Custom Forms 1
D using outlook 2007 categories through gmail Outlook VBA and Custom Forms 2
S Sending Email from Access 2007 through Outlook 2007 using template Outlook VBA and Custom Forms 13
B Programmatically scheduling WebEx meetings through Outlook Outlook VBA and Custom Forms 1
C Send the same email at 1 pm Mon through Friday Outlook VBA and Custom Forms 1
P set calendar coloring filters through VBA Outlook VBA and Custom Forms 3
F Outlook 2007 lose the attatchment when sending through external sc Outlook VBA and Custom Forms 8
P Code not moving through messages Outlook VBA and Custom Forms 2
J Move message skips messages when looping through mailbox Outlook VBA and Custom Forms 2
T Outlook setting through code(in >tools >options) Outlook VBA and Custom Forms 1
N Push a single contact through to excel Outlook VBA and Custom Forms 1

Similar threads

Back
Top