I have some sample code here you could adapt:
http://www.codeforexcelandoutlook.co...ld-that-email/
For example, the following code placed in the ThisOutlookSession module will monitor the default Inbox for new mail items. When a new message is received (or placed in the Inbox), the attachment is saved to the desktop and the message is deleted. I didn't test the code so you probably want to test it first. You didn't provide enough detail so if the emails have multiple attachments, you'll need to add additional code that checks the file extension for "pdf" before saving.
Private WithEvents MyItems As Outlook.Items
Private Sub Application_Startup()
Dim objNS As Outlook.NameSpace
Set objNS = GetNamespace("MAPI")
Set MyItems = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub MyItems_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.MailItem Then
Dim Msg As Outlook.MailItem
Dim FileN As String
Set Msg = Item
FileN = Msg.Attachments.Item(1).DisplayName
Msg.Attachments.Item(1).SaveAsFile Environ("userprofile") & "\Desktop\" & FileN
Msg.Delete
End If
End Sub
Originally Posted by
Russtar
Hi,
Really could do with your assistance in devising the following macro gents within Outlook 2000.
I need a macro that runs every time a new mail arrives in a certain subfolder that then extracts an attached pdf file and then saves it in a folder on the hd of the local machine. Finally it would be great if after doing so it would move the mail to deleted items.
Another thing to be conscious of is that I don't want any message/errors appearing on screen to advise that the macro has been successful or otherwise.
I don't ask a lot do I Is this possible?
Thanks,
Russ