Reputation: 103
I am wondering if it is possible to open the outlook of someone on an internal website to send a message with an attachment.
So far I have tried using mailto:
<a href="mailto:[email protected]">Link text</a>
And this opens outlook for them to send a message but I don't think I can add an attachment to this.
Then I tried
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
oMsg.Subject = "emailSubject";
oMsg.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
oMsg.BCC = "emailBcc";
oMsg.To = "emailRecipient";
oMsg.HTMLBody = "New Body";
oMsg.Attachments.Add("ATTACHMENTPATH");
oMsg.Display(false);
This works if I run it on my computer but when set up with a website I get this error
I believe this is because it is trying to open it on the server and outlook is not installed on the server.
Is there any way to open it on the clients side and not on the server?
Upvotes: 0
Views: 97
Reputation: 66286
You can generate an EML (MIME) file on the server and populate its contents with any data you like, including the attachments. Outlook on the client side will be able to open and show it. To make sure it is treated as an unsent message by Outlook, set the X-Unsent
MIME header to 1.
Upvotes: 1