Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / May 2008

Tip: Looking for answers? Try searching our database.

Process E-mail attachements

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Question Boy - 16 May 2008 03:13 GMT
Hello,

I have an e-mail with over 300 attachments (.eml format).  I would need some
serious help to loop through each attachment file Grab the body content and
save it as a Text file with a unique filename.

Originally I was going to save the eml file and use them but they have the
same name (don't ask) so I'd have to rename each attachment manually which is
just not doable with the quatity at hand.

Thank you for your guidance,

QB
Dmitry Streblechenko - 17 May 2008 17:16 GMT
What is the exact problem that you are having? Saving an attachment?
Processing it?

Signature

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-

> Hello,
>
[quoted text clipped - 12 lines]
>
> QB
Homr Zodyssey - 19 May 2008 13:52 GMT
I'm having a similar dilemma, I think.

I received a dozen emails.  Each of them has a dozen more emails as
attachments (.eml files).  Each of these has multiple attachmetns that are
files like PDFs, CSVs, etc.  

I'm having trouble accessing the attachments of the attachments using VBA.
Dmitry Streblechenko - 19 May 2008 19:48 GMT
You would need to first convert the EML files (which Outlook does not
understand natively) to regular messages.
There is nothing in OOM that can help you. Outlook 2002 and higher expose
IConverterSEssion object that can be used for conversion in Extended MAPI
(C++ or Delphi only).
<plug>
you can use Redemption to import EML files to Outlook (see
SafeMailItem.Import) or (if you do not want the temporary messages in
Outlook) you can create temporary standalone MSG files and import EML files:

set Session = CreateObject("Redemption.RDOSession")

set Msg = Session.CreateMessageFromMsgFile("c:\temp\test.msg", "IPM.Note",
1)

Msg.Import "c:\Temp\attach.eml", 1024

Msg.Save

MsgBox Msg.Attachments.Count

</plug>

Signature

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
-

> I'm having a similar dilemma, I think.
>
[quoted text clipped - 3 lines]
>
> I'm having trouble accessing the attachments of the attachments using VBA.
Homr Zodyssey - 29 May 2008 17:46 GMT
I misspoke when I said they were EML files.  They were MSG files.  I ended
up fixing the problem by saving each MSG file to disk then opening it.

Sub saveAttachments(mitem As MailItem)
   Dim att_mitem As MailItem
   Dim new_fname As String

   For i = 1 To mitem.Attachments.Count
       Select Case mitem.Attachments.item(i).Type
           Case olByValue
               fileCount = fileCount + 1
               new_fname = "C:\attachments\" & Right("0000" & fileCount, 4)
& "." & Right(mitem.Attachments.item(i).FileName, 3)
               LogMessage (vbTab & mitem.Attachments.item(i).FileName & "
--> " & new_fname)
               mitem.Attachments.item(i).SaveAsFile (new_fname)
           Case olEmbeddeditem
               mitem.Attachments.item(i).SaveAsFile
("C:\attachments\tmp.msg")
               Set att_mitem =
Application.CreateItemFromTemplate("C:\attachments\tmp.msg")
               LogMessage ("**" & vbTab & att_mitem.Subject)
               saveAttachments att_mitem
       End Select
   Next
   
End Sub

> You would need to first convert the EML files (which Outlook does not
> understand natively) to regular messages.
[quoted text clipped - 26 lines]
> >
> > I'm having trouble accessing the attachments of the attachments using VBA.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.