Copy Contents of Outlook Attachment - vba

I have an Outlook VBA macro that copies the contents of an email and saves them as a word document, using
activeMessage.GetInspector().WordEditor.Range.FormattedText.Copy
I'd like to change this to copy the contents of the email attachments instead. Is there a simple way to do this?

No, you will need to save the attachment as a file (Attachment.SaveAsFile), open it (depends on the file type), then access its data.

Related

Save email attachment based on the email originator and output folder

I do not have knowledge of VBA and I have researched stack overflow but can not get it working. Basically I want to save all attachments (csv files) that are moved by rule to my folder 'Test' in outlook and save in my Documents.
The rule move emails with attachments.
When I set up the rule I do not have the option to use a macro as a rule (company requirements).
Please help!
You could create a rule, refer to this link:
How To Automatically Download/Save Attachments From Outlook To A Certain Folder?
sSaveFolder = "C:\Users\DT168\Documents\outlook-attachments\"
This vba code is means where you want to save attachment. You could change this to your Documents folder URL.

Extract an Outlook attachment from the clipboard

I'm trying to access Outlook attachments from clipboard using VBA to further process the file.
The user copies an attachment to the clipboard (Right click -> Copy), opens PowerPoint, clicks a buttons and gets the presentation inserted a the end of the document.
The key part seems to access the PowerPoint file in the clipboard an save it on the file system.
Can someone help and provide a sample code for this using VBA in PowerPoint?
Many thanks!
I've found a way achieve it.
Getting filenames: Solution has been posted here: http://www.access-o-mania.de/forum/index.php?topic=17045.15
Getting the content
file size in clipboard can be obtained by GlobalSize(handle)
pointer the by GlobalLock(handle)
content using CopyMemory(destination, source, length)
Look at the clipboard contents with an app like ClipSpy. Since there is no physical file to be copied, the full file path is not included (no CF_HDROP format). But FileGroupDescriptor and FileContents formats are there.

Outlook - save/convert email body to PDF

I need a macro script to:
Convert/Print email body to PDF file
Save that file to a folder
Delete the email after
I'm pretty clueless on using scripts/macros on outlook. Would need step by step process if possible. I do have adobe program for converting installed.
You can save the message as a DOC file (OlSaveAsType.olDoc), then use the Word Object Model to convert it to PDF.

Getting contents of Outlook email attachment from networked computer

I had needed to get the attachments from an email draft so that I could check if they were an Excel file, and if so read through the file to copy/paste a range of certain text into the body of the email.
Thanks to an answer from my previous question I've figured out how to get the email attachments.
I'm working on how to get when an attachment is added to that specific email draft, but the more pressing issue is that once I've added something, how do I open it in Excel?
Dim NewMail As MailItem, oInspector As Inspector
Set oInspector = Application.ActiveInspector
Dim eAttachment As Object
'~~> Get the current open item
Set NewMail = oInspector.CurrentItem
Set eAttachment = CreateObject("Excel.Application")
With eAttachment
' Change file name to suit
.Workbooks.Open FileName:=NewMail.Attachments.Item(1).FileName
End With
This tells me that the file doesn't exist. So I look at the pathName on the attachment and find that it is set to nothing. There is no text there.
I'm thinking this has something to do with the Excel file being attached is on a computer networked to the one I am using.
I've searched, but "get contents of outlook email attachment on networked computer" didn't net me the results I wanted.
How would I gain access to the workbooks of the attached Excel file? Please note my example only uses the first attachment because for testing I am only attaching the one Excel file. When I can get the Excel file to open I will check the attachments to ensure they are excel files before I open them.
Edit: I just copied the file over to my local hard drive and tried to open the file, same issue. Am I going to have to open the file temporarily to open it? Is that what Outlook does when you edit an email attachment?
In case someone has the same issue I did - Here's what I've come to the conclusion of:
the PathName object, perhaps it is just the version of outlook that I am using, but it stores absolutely nothing. I tested it out on both of the computers in my office and my one at home, with the same result: it is just not there. Each Attachment object will have a SaveAsFile method that you can use to save the file to the temporary folder and access it from there via the usual Excel applications. This seems to be the only way, unfortunately, to read through the contents of a file attachment, even when it is simply a draft copy you are writing.
Also, what got me was the fact that I was trying, in the Excel file, to find the last cell in use, and was using the .End(xlUp) method. Remember, if you are using constants defined in the program you use, it is not defined in another. E.G. I was opening this Excel file from Outlook, technically, so trying to use xlUp gave me errors. Simply open up Excel, Word, or what have you to check the value of such constants and set them in your program.

How to save a email to a PDF format?

I want to save all my emails into a PDF format. The file must contains which look similar to the Outlook Reading Pane into Outlook 2010.
Is there a programming way to to this (cause hundreds of emails) ?
I would use openpop to retrieve all your emails. Then you could loop through each email and save the body to a pdf.