using mailto to send email with an attachment
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
How to attach blob file into HTML href=mailto:
mailto:
doesn't support attachments, but there are various ways you could achieve a similar effect:
Link to the file in a message body
You mentioned that the link needs authorisation, you could generate temporary urls that last 30 minutes (or more/less) which allow for downloads (users can then attach the file themselves)
Send the email yourself
Your service could send an email to your user (or on behalf of your user) with the attachment using something like Amazon SES, or Mailchimp, etc...
Render your PDF into HTML
It seems you are planning on attaching PDF files. Depending on the complexity of the PDF files, you could attempt to convert the PDF into email-friendly HTML using one of many tools, such as pdf2htmlEX or Pandoc.
Is it possible to add a attachment to a mail with the mailto function in actionscript 3?
From my understanding, using &attachment=file only works locally.
mailto:email@domain.com?subject=file&body=see+file&attachment=\\host\path\to\file
Where as
mailto:email@domain.com?subject=file&body=see+file&attachment=http://domain/file
does not work.
Attach File Through mailto URI
No, you can not add an attachment to a message with the mailto:
URL scheme.
mailto:
only supports header values or text/plain
content. See RFC 2368 for details.
C# MailTo with Attachment?
mailto: doesn't officially support attachments. I've heard Outlook 2003 will work with this syntax:
<a href='mailto:name@domain.com?Subject=SubjTxt&Body=Bod_Txt&Attachment=""C:\file.txt"" '>
A better way to handle this is to send the mail on the server using System.Net.Mail.Attachment.
public static void CreateMessageWithAttachment(string server)
{
// Specify the file to be attached and sent.
// This example assumes that a file named Data.xls exists in the
// current working directory.
string file = "data.xls";
// Create a message and set up the recipients.
MailMessage message = new MailMessage(
"jane@contoso.com",
"ben@contoso.com",
"Quarterly data report.",
"See the attached spreadsheet.");
// Create the file attachment for this e-mail message.
Attachment data = new Attachment(file, MediaTypeNames.Application.Octet);
// Add time stamp information for the file.
ContentDisposition disposition = data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(file);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
// Add the file attachment to this e-mail message.
message.Attachments.Add(data);
//Send the message.
SmtpClient client = new SmtpClient(server);
// Add credentials if the SMTP server requires them.
client.Credentials = CredentialCache.DefaultNetworkCredentials;
try {
client.Send(message);
}
catch (Exception ex) {
Console.WriteLine("Exception caught in CreateMessageWithAttachment(): {0}",
ex.ToString() );
}
data.Dispose();
}
Related Topics
Mystery White Space Underneath Image Tag
How to Get the File Path from HTML Input Form in Firefox 3
Why Are Flex Items Not Wrapping
How to Limit the Visible Options in an HTML <Select> Dropdown
How to Disable a Checkbox Based on Conditions in Angular 6
How to Remove Hover Effect from Bootstrap Button
Stretch and Scale CSS Background
How to Make an Image Center (Vertically & Horizontally) Inside a Bigger Div
How to Select the Last Element With a Specific Class, Not Last Child Inside of Parent
How to Put Two Button in the Same Line Using Only HTML and CSS
How to Set Filename for Base64 Rendered Pdf Using Object Tag
Setting Attribute Disabled on a Span Element Does Not Prevent Click Events
File Input 'Accept' Attribute - Is It Useful
Disabled Form Inputs Do Not Appear in the Request
How to Create a Link to a Local File on a Locally-Run Web Page
How to Add Images in Select List
Failed to Load Resource: the Server Responded With a Status of 404 (Not Found) CSS
In Angular 4, How to Dynamically Set Min Date and Max Date in Date Picker