如何使用富文本框内容包含字符串&图像为电子邮件正文消息? [英] How to have a richTextBox content contains Strings & Image as Email Body Message?

查看:65
本文介绍了如何使用富文本框内容包含字符串&图像为电子邮件正文消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是VS2010。我通过CDO准备小型电子邮件应用程序。

在该应用程序中,我有一个包含字符串和字符串的richTextBox。图片.....

问题是,虽然我希望将RichTextBox内容添加为EMail Body

它只发送了richTextBox字符串...而且它有不发送richTextBox

图像...为此需要改变......?感谢您的帮助...... !!!



<前一行=c#>我的编码: -
======= ====
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient( smtp .gmail.com);

mail.From = new MailAddress( MyEmail@MyDomain.com);
mail.To.Add( MyToAddress@ToDomain.com);
mail.Subject = textBox1.Text;

mail.IsBodyHtml = true ;
mail.Body = richTextBox1.Text; ???????????可能在这里

SmtpServer.Port = 587 ;
SmtpServer.Credentials = new System.Net.NetworkCredential( FmAddrs@FmDomain.com MyPsword);
SmtpServer.EnableSsl = true ;

SmtpServer.Send(邮件);





谢谢&问候

Paramu @ Paranthaman

解决方案

你拿属性文本,但是你需要的不是文字。你需要使用内容类型text / rtf或application.rtf(不要与richtext混淆,然后是text / enriched,两者都已经过时了,请参阅下面的第二个链接)。请参阅:

http://en.wikipedia.org/wiki/Internet_media_type [< a href =http://en.wikipedia.org/wiki/Internet_media_typetarget =_ blanktitle =New Window> ^ ],

http://en.wikipedia.org/wiki/Rich_Text_Format [ ^ ]。



此处维护媒体类型的标准:http://www.iana.org/assignments/media-types/media-types.xhtml [ ^ ]。



如需与 System.Net.Mail.MailMessage 一起使用,请参阅:

HTTP://msdn.microsof t.com/en-us/library/system.net.mail.mailmessage%28v=vs.110%29.aspx [ ^ ](搜索内容类型,

http:/ /msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.bodyencoding(v=vs.110).aspx [ ^ ]。



-SA


Hi, Iam using VS2010. Iam preparing small EMail Application by CDO.
In that application I have a richTextBox contains Strings & Images.....
The Problem is, while I wish to add a RichTextBox content as EMail Body
It has sending the richTextBox strings only...And It has not sending the richTextBox
Image... For that anything need to change ....? Thanks for the helps....!!!

My Codings :-
===========
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

mail.From = new MailAddress("MyEmail@MyDomain.com");
mail.To.Add("MyToAddress@ToDomain.com");
mail.Subject = textBox1.Text;

mail.IsBodyHtml = true;
mail.Body = richTextBox1.Text ;    ??????????? May Be Here 

SmtpServer.Port = 587;
SmtpServer.Credentials=new System.Net.NetworkCredential("FmAddrs@FmDomain.com", "MyPsword");
SmtpServer.EnableSsl = true;

SmtpServer.Send(mail);



Thanks & Regards
Paramu @ Paranthaman

解决方案

You take the property Text, but what you need is not text. You need to use the content-type "text/rtf" or "application.rtf" (not to be confused with "richtext", followed by "text/enriched", both pretty much obsolete, see the second link below). Please see:
http://en.wikipedia.org/wiki/Internet_media_type[^],
http://en.wikipedia.org/wiki/Rich_Text_Format[^].

The standard for media types is maintained here: http://www.iana.org/assignments/media-types/media-types.xhtml[^].

For the use with System.Net.Mail.MailMessage, please see:
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage%28v=vs.110%29.aspx[^] (search for "content-type),
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.bodyencoding(v=vs.110).aspx[^].

—SA


这篇关于如何使用富文本框内容包含字符串&amp;图像为电子邮件正文消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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