1
votes

For instance, I have a word document as an Outlook attachment. I want to have a C# program that will find that file's local location, process it into a PDF, and then change the email's attachment to that new PDF file. The next time that attachment is opened, it will open the PDF and not the word document.

Edit 1: The email attachment is in my inbox, as someone has sent this file to me. I am able to edit the actual word file just like any other document just fine. I figure this would be possible by adding

Is this function possible? and remoreceived chments to existing recieved emails as well.

1
Is this before sending? Or in the inbox? Can you talk us through why you want to do this? Also please provide a minimal reproducible example of your progress so far. - mjwills
This might be helpful msdn.microsoft.com/en-us/vba/outlook-vba/articles/… this would be easier as an outlook addin rather than via interop. - Davesoft

1 Answers

2
votes

Yes, that is possible. You can develop an Outlook COM add-in (for example, a VSTO based one). The Attachment class provides the SaveAsFile method which saves the attachment to the specified path. Then you can automate Word where you may open the file just saved and re-save it using the .pdf file format. Or you may consider using third-party components that don't require Word installed on the system. After converting the document and getting the required pdf file you may remove an old attachment and re-add a new one. The Attachments.Add creates a new attachment in the Attachments collection.

You may find the following articles helpful: