无法更改文字的字体或颜色 [英] cannot change font or color of text

查看:75
本文介绍了无法更改文字的字体或颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 8.1中编写电子邮件时无法更改文本的字体或颜色。尝试在MSN中更改为HTML"帮助"但是没有回复

解决方案

你好cheme1,


感谢您在此发帖。  ;


如果你想发送带有字体和颜色的邮件,你可以试试下面的代码。'

 

使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Net;
使用System.Net.Mail;
使用System.Text;
使用System.Threading.Tasks;

命名空间ConsoleApp
{
class Send_mail
{
static void Main(string [] args)
{
string smtpAddress =" smtp.live.com" ;;
int portNumber = 587;
bool enableSSL = true;

string emailFrom =" xxxx@hotmail.com" ;;
string password =" xxxxxx" ;;
string emailTo =" xxxxx@xxx.com" ;;


string s =" Hello" ;;
string subject = s;
string message1 =" something" ;;
string message2 ="< font face ='Arial Black'color ='red'> something< / font>" ;; //"这是第一行。< br>< b>粗体< / b>"
string message ="我的消息是" + message1 +"和" + message2;
string body = message; //"你好,我只是写这个来说嗨!";

使用(MailMessage mail = new MailMessage())
{
mail.From = new MailAddress(emailFrom);
mail.To.Add(emailTo);
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
//如果要发送纯文本,可以设置为false。

//mail.Attachments.Add(new Attachment(" C:\\SomeFile.txt"));
//mail.Attachments.Add(new Attachment(" C:\\SomeZip.zip"));

使用(SmtpClient smtp = new SmtpClient(smtpAddress,portNumber))
{
smtp.Credentials = new NetworkCredential(emailFrom,password);
smtp.EnableSsl = enableSSL;
smtp.Send(mail);
}
}
}
}
}




最好的问候,


Wendy


cannot change font or color of text in writing email in windows 8.1. Tried changing to HTML in MSN "help" but there is no response

解决方案

Hi cheme1,

Thank you for posting here. 

If you want to send mail with font and color, you could try the code below.'

using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Mail; using System.Text; using System.Threading.Tasks; namespace ConsoleApp { class Send_mail { static void Main(string[] args) { string smtpAddress = "smtp.live.com"; int portNumber = 587; bool enableSSL = true; string emailFrom = "xxxx@hotmail.com"; string password = "xxxxxx"; string emailTo = "xxxxx@xxx.com";

string s = "Hello"; string subject = s; string message1 = "something"; string message2 = "<font face='Arial Black' color='red'>something</font>";//"this is first line.<br><b>bold</b>" string message = "My message is " + message1 + " and " + message2; string body = message;//"Hello, I'm just writing this to say Hi!"; using (MailMessage mail = new MailMessage()) { mail.From = new MailAddress(emailFrom); mail.To.Add(emailTo); mail.Subject = subject; mail.Body = body; mail.IsBodyHtml = true; // Can set to false, if you are sending pure text. //mail.Attachments.Add(new Attachment("C:\\SomeFile.txt")); //mail.Attachments.Add(new Attachment("C:\\SomeZip.zip")); using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber)) { smtp.Credentials = new NetworkCredential(emailFrom, password); smtp.EnableSsl = enableSSL; smtp.Send(mail); } } } } }


Best Regards,

Wendy


这篇关于无法更改文字的字体或颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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