Programmatically Attach PDF from MemoryStream to Outlook E-Mail Items - c#

Would it be possible to attach PDF from MemoryStream or other functions to Outlook E-Mail Items MailItem.Attachment.add(), rather than from the file on the hard disk by passing the physical path of file in this method.
I would like to create the Outlook mailitem for the users with the PDF attached programmatically, and let the users to review and send out the email by themselves.
Thank you in advance.

Not using the Outlook Object Model - Attachments.Add will only let you pass a file name for the olByValue attachments. Extended MAPI (C++ or Delphi) only operates on IStream objects (IAttach::OpenProperty(PR_ATTACH_DATA_BIN, IID_IStream,...)), Redemption (I am its author) lets you pass file name, url, array, IStream or IStorage to RDOAttachments.Add.

Related

Create MailMessage object from .msg File Path?

Is there a way to create a MailMessage object from a directory path of a .msg file?
Such as MailMessage x = new MailMessage("path")
There is no direct conversion between these two entities out of the box - the Outlook message file and the MailMessage class from the .net framework. You can automate Outlook to get the instance of the MSG file instantiated using the NameSpace.OpenSharedItem method which is used to open iCalendar appointment (.ics) files, vCard (.vcf) files, and Outlook message (.msg) files.
You can also use Redemption for that, look for RDOSession.GetMessageFromMsgFile.
Thanks for the replies but I found the answer on this existing post: C# Outlook interop and OpenSharedItem for opening MSG files
Like Eugene said, I used the Microsoft.Office.Interop.Outlook.Application to open the .msg file via Outlook.

Change what file an Outlook attachment points to

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.
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:
Attach a File to a Mail Item
Modify an Attachment of an Outlook Email Message
How To: Add an attachment to an Outlook e-mail message

C# Outlook Plugin - Get full path (origin source file) of attachment in mail?

I want to get full path (origin source file) of attachment in mail Outlook, I use object Attachment in Outlook to get Pathname: Attachment.PathName, but it returns null.
So, how can I get the source file's link?
Example: this is a link to image attachment in a my email
Email attachments do not have a source path. Once they were sent, they are part of the message, not part of any file system, regardless of their source path. The best you can do is get the attachment file name.
As you can read here, Attachment.PathName only works with linked files, not attached files:
Remarks:
This property is only valid for linked files.

C# Lotus Notes - multiple .nsf files

I send mails from C# code via Lotus Notes and it works really fine - with Win7 and WinXP.
But some users of my program have multiple .nsf files in the directory, like 'user1.nsf' and 'old-user1.nsf'.
How can I retieve which of these files is the active database I have to use?
If your code runs on users machine then you have "MailFile" and "MailServer" variables in notes.ini file.
Where is this directory located?
You don't need to care which mail database is active if you are sending emails. Just create a new NotesDocument object in memory, fill out the appropriate properties (subject, Body, etc), and then call the Send method on that object. Notes takes care of the rest.
If you need to get the mail database information for a user for another reason, there is a GetUserInfo method for that on the NotesRegistration class
Or in formulas, there is the #MailDbName formula.
If you're just using the user's mail file, in LotusScript you can just use
Call notesDatabase.OpenMail
That way, you never need to bother with where the mail file is - you get the handle to it seemlessly.

How to create Outlook's new mail window with attachement in?

I'd like add to my app function allowing sending email via Outlook same as eg Adobe Reader does.
So after pressing email button I'd like to see Outlook's native 'new mail' window with my document attached in.
Any idea how to archive that?
Why not interop?
http://support.microsoft.com/kb/819398
Not quite a solution, but more of a hint: maybe creating an *.eml file with your attachment and opening it (as a new mail window) would help?

Categories

Resources