using mailto to send email with an attachment
HtmlHtml Problem Overview
How can i send an email with an attachment (either local file or a file in the intranet) using outlook 2010?
<a href="mailto:[email protected]?subject=my report&body=see attachment&attachment=c:\myfolder\myfile.txt">
doesn't seem to work.
Html Solutions
Solution 1 - Html
Nope, this is not possible at all. There is no provision for it in the mailto:
protocol, and it would be a gaping security hole if it were possible.
The best idea to send a file, but have the client send the E-Mail that I can think of is:
- Have the user choose a file
- Upload the file to a server
- Have the server return a random file name after upload
- Build a
mailto:
link that contains the URL to the uploaded file in the message body
Solution 2 - Html
this is not possible in "mailto" function.
please go with server side coding(C#).make sure open vs in administrative permission.
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";
string body = "emailMessage";
oMsg.HTMLBody = "body";
oMsg.Attachments.Add(Convert.ToString(@"/my_location_virtual_path/myfile.txt"), Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
oMsg.Display(false); //In order to displ
Solution 3 - Html
If you are using c# on the desktop, you can use SimpleMapi. That way it will be sent using the default mail client, and the user has the option of reviewing the message before sending, just like mailto:
.
To use it you add the Simple-MAPI.NET package (it's 13Kb), and run:
var mapi = new SimpleMapi();
mapi.AddRecipient(null, address, false);
mapi.Attach(path);
//mapi.Logon(ParentForm.Handle); //not really necessary
mapi.Send(subject, body, true);
Solution 4 - Html
what about this
<FORM METHOD="post" ACTION="mailto:[email protected]" ENCTYPE="multipart/form-data">
Attachment: <INPUT TYPE="file" NAME="attachedfile" MAXLENGTH=50 ALLOW="text/*" >
<input type="submit" name="submit" id="submit" value="Email"/>
</FORM>