在ASP.NET中创建一个电子邮件,然后在默认邮件程序中打开它以进行编辑,然后从默认邮件程序发送

时间:2021-08-15 17:03:03

My website creates an email from an HTML template using MailDefinition and ending up with a System.Net.Mail.MailMessage object.

我的网站使用MailDefinition从HTML模板创建一封电子邮件,最后使用System.Net.Mail.MailMessage对象。

Usually, I just call the Net.Mail.SmtpClient.Send method and the email is sent.

通常,我只是调用Net.Mail.SmtpClient.Send方法并发送电子邮件。

Now I need to be able to open the created email in the clients default mail program and then they click their email programs send button to send it.

现在我需要能够在客户端默认邮件程序中打开创建的电子邮件,然后他们单击他们的电子邮件程序发送按钮发送它。

Has anyone got an ideas on how to proceed?

有没有人有关于如何进行的想法?

This is in VS2005.

这是VS2005。

2 个解决方案

#1


You'll want to use a mailto: link -- which means, if this is the only method your users will have to send emails, that your code that uses SmtpClient will no longer be used.

您将需要使用mailto:link - 这意味着,如果这是您的用户必须发送电子邮件的唯一方法,那么将不再使用使用SmtpClient的代码。

Unfortunately, unless this is an intranet-only application, you don't have too many other options, as browsers will not give you enough permissions to execute code against that machine's default email client.

不幸的是,除非这是一个仅限Intranet的应用程序,否则您没有太多其他选项,因为浏览器不会为您提供足够的权限来执行针对该计算机的默认电子邮件客户端的代码。

#2


The two ways I can think of are:

我能想到的两种方式是:

  • use a < a href="mailto:[email address here">-Element. But you can't set anything except the recipient this way
  • 使用 - 元素。但是你不能以这种方式设置除收件人以外的任何东西

  • You could send a .eml-File with content-disposition "attachment", that should be opened by the user's default mail program
  • 您可以发送带有内容处置“附件”的.eml文件,该文件应由用户的默认邮件程序打开

Edit: I just saw Jeremy's link and found out that you actually can supply body/subject/cc with a mailto-link. You can't supply attachments, though (I think)

编辑:我刚看到Jeremy的链接,发现你实际上可以通过mailto-link提供body / subject / cc。你不能提供附件(我认为)

#1


You'll want to use a mailto: link -- which means, if this is the only method your users will have to send emails, that your code that uses SmtpClient will no longer be used.

您将需要使用mailto:link - 这意味着,如果这是您的用户必须发送电子邮件的唯一方法,那么将不再使用使用SmtpClient的代码。

Unfortunately, unless this is an intranet-only application, you don't have too many other options, as browsers will not give you enough permissions to execute code against that machine's default email client.

不幸的是,除非这是一个仅限Intranet的应用程序,否则您没有太多其他选项,因为浏览器不会为您提供足够的权限来执行针对该计算机的默认电子邮件客户端的代码。

#2


The two ways I can think of are:

我能想到的两种方式是:

  • use a < a href="mailto:[email address here">-Element. But you can't set anything except the recipient this way
  • 使用 - 元素。但是你不能以这种方式设置除收件人以外的任何东西

  • You could send a .eml-File with content-disposition "attachment", that should be opened by the user's default mail program
  • 您可以发送带有内容处置“附件”的.eml文件,该文件应由用户的默认邮件程序打开

Edit: I just saw Jeremy's link and found out that you actually can supply body/subject/cc with a mailto-link. You can't supply attachments, though (I think)

编辑:我刚看到Jeremy的链接,发现你实际上可以通过mailto-link提供body / subject / cc。你不能提供附件(我认为)