c# rtf to html,C#读取.html或.rtf并将其用作Mail.Body

string Mailto = "username@domainname";

string MailCc = "username@domainname";

string Subject = "Test";

ReadSignature();

Outlook.Application app = new Outlook.Application();

Outlook.MailItem mail = (Outlook.MailItem)app.CreateItem(Outlook.OlItemType.olMailItem);

mail.To = Mailto;

mail.CC = MailCc;

mail.Subject = Subject;

mail.HTMLBody = "

This just a test" + signature;

mail.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;

mail.Display(true);

I want to open a mail on buttonclick as shown above. Works perfectly.

No I'm trying to figure out how I could read out a file and use it as body.

Background: I want to have like 4 different Mails which are all formatted nicely. So I thought I could write these files as .rtf, .doc, .msg or whatsoever and just copy these files into mail.htmlbody.

Talk1:

read the html-file and assign it to mail.HTMLBody?

Solutions1

Ok right. Was pretty easy actually ;-)

//Local File

String htmlCode = File.ReadAllText(@"C:\Test.html", Encoding.Default);

//Webfile

WebClient client = new WebClient();

String htmlCode = client.DownloadString(@"http://www.google.com");

mail.HTMLBody = htmlCode + signature;

Talk1:

"htmlCode + signature" will not produced a valid HTML string. You cannot just concatenate two HTML documents, you must merge them.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值