邮件消息和mailto通讯.... [英] mail message and mailto communication....

查看:145
本文介绍了邮件消息和mailto通讯....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用邮件类的方法.
只是想知道是否可以将邮件消息"mm.body"的属性之一与mailto协议进行同步.

代码如下:

I have a method that uses the mail message class.
Just wondering if it is possible to sync the one of the properties of mail message "mm.body" with the mailto protocol.

Code below:

protected void emailBody()
       {
           MailMessage mm = new MailMessage();

           mm.IsBodyHtml = true;
           mm.Body = PageResult;



       }





<td>
                <asp:HyperLink ID="HyperLink1" A href="mailto:&Subject=Services Quote&body="  runat="server">Email Quote</asp:HyperLink>

            </td>

推荐答案

没有"mailto"这样的协议. "mailto:"只是URI 模式,请参阅:

http://en.wikipedia.org/wiki/URI_scheme [ http://en.wikipedia.org/wiki/URL [ http://en.wikipedia.org/wiki/URI [
通常,单击的结果会使OS建议用户使用某些默认电子邮件应用程序发送电子邮件.您不能对点击所引起的行为做出任何假设:客户端系统可能会或可能不会设置任何电子邮件软件,即使在点击时互联网连接也可能会或可能不可用.

—SA
There is not such protocol as "mailto". "mailto:" is just the URI schema, please see:

http://en.wikipedia.org/wiki/URI_scheme[^].

See also:
http://en.wikipedia.org/wiki/URL[^],
http://en.wikipedia.org/wiki/URI[^].

It has nothing to do with the behavior of your Web application and its server part, not related to MainMessage or anything at all. Not that it is not possible to synchronize, the right answer would be: there is nothing to synchronize.

What happens is: your whole code is already executed, as it all happens between HTTP request and HTTP response. If does not matter is you sent some messages to some server, received some messages or anything like that. The pure result of all of this will be delivered to you in HTTP response; and your Web browser has rendered some HTML page, possibly with some URLs, and some of the URLs could be "mailto:". It means nothing for you Web application; it can only be processed on the client side.

Usually, the result of the click causes OS to suggest the user to sent a e-mail message using some default e-mail application. You cannot use any assumption on the behavior caused by the click: the client system may or may not have any e-mail software set up, even the Internet connection may or may not be available at the moment of click.

—SA


[将评论中的后续问题解答到解决方案1]

[Answering follow-up questions from the comments to Solution 1]

Andrew Chambers写道:
Andrew Chambers wrote:

尊敬的SA,我想将网页的正文插入电子邮件客户端正文中. Outlook是电子邮件客户端.我应该看什么课吗?

Hi SA, I would like to insert the body of my webpage into the email clients body. Outlook is the email client. Are there any classes I should look at?

Andrew,

从您的问题中,我感到您误解了电子邮件操作,或者可能误解了Web应用程序以及HTTP中服务器和客户端部分的角色.

您最近的问题的第一部分假设您想从Web应用程序发送电子邮件.并且您正在使用在服务器端工作的类MailMessage.它与您的Outlook电子邮件客户端无关.发送电子邮件时,您不知道收件人的电子邮件客户端.

您在Web应用程序中所做的是:您在Web应用程序中生成了一些Web表单;它可以是一个简单的静态HTML文件.它应该具有HTTP请求的"POST"方法.您的服务器端应获取发布数据并从中发送电子邮件.在其他情况下,应使用服务器端可用的数据(例如要发送的HTML页面),电子邮件地址和其他标题.

电子邮件不过是一个文本数据块.即使您有附加" ZIP文件或图像,或其他任何内容,也始终会以文本格式(使用base64等)对这些数据进行编码.全部使用 multipart MIME消息完成.所有部分都合并为一个文本.如果您有任何* .EML文件-每个此类文件都是通过电子邮件发送的确切原始数据包.

现在,您需要服务器上可用的某些消息传输代理.通常,这是位于单独(或相同)主机上的单独服务器,具有实现某些邮件协议的单独(或相同)URI或域名.通常,这是SMTP服务器,但也可以是其他服务器.如果您自己托管HTTP和其他服务器,则需要与Web托管提供商进行核对或自行设置适当的服务器.

它与您的Outlook或任何其他客户端无关.这是您需要了解的东西.请阅读以下内容:

http://en.wikipedia.org/wiki/Email [ http://en.wikipedia.org/wiki/Email_client [ http://en.wikipedia.org/wiki/Mail_transfer_agent [ http://en.wikipedia.org/wiki/SMTP [ http://en.wikipedia.org/wiki/Request_for_Comments [ http://en.wikipedia.org/wiki/MIME [ http://www.ietf.org/rfc/rfc1867.txt [ http://www.iana.org/assignments/message-headers/perm-headers .html [ ^ ].

请使用.NET System.Net.Mail:
查找代码示例 http://www.systemnetmail.com/faq/3.1.3.aspx [ ^ ].

警告!如果您需要根据用户的提交内容来形成邮件,请格外小心.利用您的HTTP主机将其转变为发送垃圾邮件或其他内容的僵尸,这太容易了.请参阅我最近的帖子:
无法发送邮件,它显示了以下代码中的错误. [

Andrew,

From your questions, I feel you misunderstand e-mail operation or maybe roles of server and client parts in Web application as well as HTTP.

First part of your recent question assume that you want to sent e-mail from your Web application; and you are using the class MailMessage which works on the server side. It has nothing to do with your Outlook e-mail client. When you send e-mail, you don''t know the e-mail client of the receiver.

What you do in your Web application is: you generate some Web form in your Web application; it can be a simple static HTML file. It should have the "POST" method of HTTP request. Your server side should get the post data and make e-mail out of it. In other cases, you should use the data available on your server side (such as HTML page you want to send), e-mail address and other headers.

The e-mail message is nothing more but a single block of text data. Even if you have ZIP files "attached" or images, or anything else, you always encode this data in a text format (using base64, etc.). This is all done using multipart MIME messages. All parts are combined into just one single text. If you have any *.EML files — each such file is an exact raw packet send via e-mail.

Now, you need some message transfer agent which is available on you server side. Usually, this is a separate server on a separate (or the same) host with separate (or the same) URI or domain name implementing some mail protocol. Most typically, this is a SMTP server, but it can be something else. You need to check up with your Web hosting provider or setup appropriate server by yourself, if you self-host your HTTP and other servers.

It has nothing to do with you Outlook or any other clients. This is something you need to understand. Please read this:

http://en.wikipedia.org/wiki/Email[^],
http://en.wikipedia.org/wiki/Email_client[^],
http://en.wikipedia.org/wiki/Mail_transfer_agent[^],
http://en.wikipedia.org/wiki/SMTP[^].

Better now?

Now, let''s see how multipart messages could be created. Basically, creation of such messages in nothing more but composing some text following e-mail standard, specified in a number of IETF RFC documents.

Please see:
http://en.wikipedia.org/wiki/Request_for_Comments[^].

MIME RFCs are listed here:
http://en.wikipedia.org/wiki/MIME[^].

See also:
http://www.ietf.org/rfc/rfc1867.txt[^].

See also: http://www.iana.org/assignments/message-headers/perm-headers.html[^].

Please find a code sample using .NET System.Net.Mail:
http://www.systemnetmail.com/faq/3.1.3.aspx[^].

Warning! If you ever need to form a mail based on user''s submission: be extra careful. It''s way too easy to exploit your HTTP host to turn it into a zombie sending spam or something else. Please see my recent post:
unable to send mail , it showing the error in below code .[^].

—SA


这篇关于邮件消息和mailto通讯....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆