Saving Outlook Attachments

mikec

Registered User.
Local time
Today, 00:28
Joined
Dec 17, 1999
Messages
22
Hello,

I would like to create some code which on a daily basis locates a specific mail message in an Outlook public folder and the saves the attachment. The message will have the same subject text each day.

Thanks,

Mike
 
Mike,

I have a colleague at work who asked me if I knew how to do the exact same thing yesterday. He was looking to create the same condition in Outlook using the rules wizard but from what he said it required added the code as a custom rule rather than doing it through Access.

He searched various web resources looking for something similar but had no joy. He did however say that he read something which led him to believe it was possible so if he comes up with something I'll let you know.
 
Cheeky,

Thanks for your efforts. I actually was able to figure it out - maybe it can help you.

The following example locates the first post in the public folder "BST_Postings" with a subject of "Access Type Dump". It then saves the attachment to a network location.

You'll need to set a reference to Microsoft Outlook 9.0 Object Library.

Dim oOL As Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder
Dim MailMess As Outlook.MailItem
Dim MessAttach As Outlook.Attachments

Set oOL = CreateObject("Outlook.Application")
Set oNS = oOL.GetNamespace("MAPI")
Set oFolder = oNS.Folders("Public Folders").Folders("All Public Folders").Folders("BST_Postings")
Set MailMess = oFolder.Items.Find("[Subject] = ""Access Types Dump""")
Set MessAttach = MailMess.Attachments
MessAttach.Item(1).SaveAsFile "\\dopc02\store\mds\atfile\atfile.csv"
 

Users who are viewing this thread

Back
Top Bottom