ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening an attachment of a message that has a message as attachmen (https://www.excelbanter.com/excel-programming/351830-opening-attachment-message-has-message-attachmen.html)

vetron

Opening an attachment of a message that has a message as attachmen
 
Lets suppose I have 2 messages in the input folder in Outlook 2000.
Each message as 2 attachments.
The first attachment of the first message is a message with 2 attachments.
Each attachment has 1 pdf document.
Like this:

Outlook 2000
---Infolder
------Message1 (has 2 attachments)
---------Attachment1 (is a message)
------------This message has an attachment: Document1.pdf.
---------Attachment2 (is a message)
------------This message has an attachment: Document2.pdf.
------Message2 (has 2 attachments)
---------Attachment n (is a message)
---------Attachment n+1 (is a message)

How can I open Document1.pdf using VBA?

So far, I have done this:

Set myOlApp = CreateObject("Outlook.Application")
Set b = myOlApp.Session.Folders("InFolder")
For x = 1 To b.Items(1).Attachments.Count
---at this point I can display the first message:
---b.items(1).display
---it is possible to save that message:
---b.items(1).attachments(x).saveasfile(c:\temp\ms g1.msg)
---but what I really want to do is to open the attachment of this message
i.e. Document1.pdf.
---How?
Next

Thanks


All times are GMT +1. The time now is 12:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com