Html 使用 mailto 发送带有附件的电子邮件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5233556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:11:56  来源:igfitidea点击:

using mailto to send email with an attachment

html

提问by Benchik

How can i send an email with an attachment (either local file or a file in the intranet) using outlook 2010?

如何使用 Outlook 2010 发送带有附件(本地文件或 Intranet 中的文件)的电子邮件?

<a href="mailto:[email protected]?subject=my report&body=see attachment&attachment=c:\myfolder\myfile.txt">

doesn't seem to work.

似乎不起作用。

回答by Pekka

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.

不,这根本不可能。mailto:协议中没有对此做出规定,如果可能的话,这将是一个巨大的安全漏洞。

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
  • 让用户选择一个文件
  • 将文件上传到服务器
  • 上传后让服务器返回一个随机文件名
  • mailto:在消息正文中构建一个包含上传文件的 URL的链接

回答by AlexDev

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:.

您可以使用SimpleMapi。这样,它将使用默认邮件客户端发送,并且用户可以选择在发送前查看邮件,就像mailto:.

To use it you add the Simple-MAPI.NETpackage (it's 13Kb), and run:

要使用它,请添加Simple-MAPI.NET包(13Kb),然后运行:

var mapi = new SimpleMapi();
mapi.AddRecipient(null, address, false);
mapi.Attach(path);
//mapi.Logon(ParentForm.Handle);    //not really necessary
mapi.Send(subject, body, true);

回答by Boopathi.Indotnet

this is not possible in "mailto" function.

这在“mailto”功能中是不可能的。

please go with server side coding(C#).make sure open vs in administrative permission.

请使用服务器端编码(C#)。确保在管理权限中打开 vs。

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

回答by John Smith

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>