首页 新闻 会员 周边

发送html内容到qq,126等邮箱内容去除了style样式?

0
悬赏园豆:200 [待解决问题]

我用exchange 服务器 方式 发送邮件  发送内容类似<p><span style="color:#03333">cehsi</span><p>,到邮箱后只有文本 ,已经设置邮件类型为html ,怎么处理内容让邮件内容正确显示样式颜色字体

问题补充:

我用的c#语言 使用的 emailmessage 这个类做的发送邮件

ldg的主页 ldg | 初学一级 | 园豆:2
提问于:2017-07-22 17:25
< >
分享
所有回答(4)
0

使用HTML格式化邮件,修改mail()函数所发送的标头;

<?php
//start building the mail string
$msg = "<p><strong>Name:</strong>".$_POST['name']."</p>";
$msg .= "<p><strong>E-Mail:</strong>".$_POST['email']."</p>";
$msg .= "<p><strong>Message:</strong>".$_POST['message']."</p>";

//set up the email
$recipient="you@yourdomain.com";
$subject="From Submission Results";
$mainheaders="MIME_Version:1.0\r\n";
$mainheaders .= "Content-type:text/html;charset=ISO-8859-1\r\n";
$mainheaders .="From:My Web Site <defaultaddress@yourdomain.com>\n";
$mainheaders .= "Reply-To:"._POST['email'];

//send the eamil
mail($recipient,$subject,$msg,$mailheaders);
?>
//下面是HTML代码
<!DOCTYPE html>
<html>
<head>
<title>...</title>
</head>
<body>
<p>Thanks,<strong><?php echo $_POST['naem']?></strong>,for your message</p>
<p>Your e-mail address:<strong><?php echo $_POST['email'];?></strong></p>
<p>Yout message :</br><?php echo $_POST['message'];?></p>
</body>
</html>

用PHP写的,希望可以帮助到你

曹婷婷 | 园豆:149 (初学一级) | 2017-07-23 09:15
0

CSS用style属性,具体参考:

http://blog.csdn.net/cndotaci/article/details/4435893

ycyzharry | 园豆:25651 (高人七级) | 2017-07-23 10:55

转载的内容我看过 ,可我使用多文本编辑器直接把内容发过去,也不知道怎么去改内容合适

支持(0) 反对(0) ldg | 园豆:2 (初学一级) | 2017-07-23 23:42
0

要在setContent后面写上text/html;charset=UTF-8,详细请看:http://www.cnblogs.com/yeyingyx/p/7224128.html


import java.util.Properties

import javax.mail.*;
import javax.mail.internet.*;


public class MailUtil {
//传入发邮件的地址和邮件激活码
public static void sendMail(String to,String code){
//发送邮件的服务器
String host = "smtp.qq.com";
//用户名
String username="2238071096@qq.com";
//第三方客户端验证密码,需要在QQ邮箱的账户/SMTP/POP3/IMAP下开启/SMTP/POP3
//发短信得到第三方客户端登录验证密码
String password="************";
//Session对象
Properties props = new Properties();
props.put("mail.smtp.host", host);
//发送邮件的端口号
props.put("mail.smtp.port", "465");
/* props.put("mail.transport.protocol", "smtp");*/
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.ssl.enable","true");///使用 STARTTLS安全连接
props.put("mail.debug", "true");
Session session = Session.getDefaultInstance(props);

//Message对象
MimeMessage message = new MimeMessage(session);
// 设置发件人
try {
message.setFrom(new InternetAddress(username));
//设置收件人
message.setRecipients(Message.RecipientType.TO,to);
//设置主题
message.setSubject("来自于xionger商城的账号激活邮件");

//设置内容
message.setContent("<h1>来自于熊二商城的账号激活邮件!激活请点击以下链接</h1><br><h3><a href='http://localhost:8888/shop/usersActive.action?Users.u_code="+code+"'>http://localhost:8888/shop/register.action?code="+code+"</a></h3>","text/html;charset=UTF-8");

message.saveChanges(); // implicit with send()

Transport transport = session.getTransport("smtp");

transport.connect(host, username, password);

transport.sendMessage(message, message.getAllRecipients());

transport.close();



} catch (AddressException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}

侠客夜莺 | 园豆:202 (菜鸟二级) | 2017-07-23 11:40
0

用的是MailMessage吧? 类名写错了都 有设置IsBodyHtml等于true吗

大杯美式不加糖不加奶 | 园豆:994 (小虾三级) | 2017-07-24 09:15

用的是 exchange.webservices.data.emailmessage,  不是net.mail.mailmessage!

支持(0) 反对(0) ldg | 园豆:2 (初学一级) | 2017-07-24 14:26
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册