JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java SE 討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
作者 javamail 收件人顯示的問題
chuang5089





發文: 254
積分: 0
於 2011-12-05 18:07 user profilesend a private message to usersend email to chuang5089reply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
請問一下

當我使用java mail 發送信件時在使用者收到的信件的寄件人如何不要顯示 email address 而是顯示其他我所輸入的中文名稱?

我在outlook 上可以設定"你的名稱例如自己的公司Title "不知是否可行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
            InternetAddress[] address=null;
            address = InternetAddress.parse("****@lotrich.com",false);
            Properties props = new Properties();
            props.put("mail.smtp.host", "mail.****.com.tw");
            props.put("mail.transport.protocol", "smtp");
            props.put("mail.smtp.auth", "true");
            javax.mail.Session sessmail = javax.mail.Session.getInstance(props);
            MimeMessage msg = new MimeMessage(sessmail);
  
            msg.setFrom(new InternetAddress("****.tw"));
  
            
            address = InternetAddress.parse("*****",false);
            msg.setRecipients(Message.RecipientType.TO, address);
 
            msg.setSubject("道相報商店");   
            msg.setSentDate(new Date()); //設定送信的時間  
      
            msg.setContent(" 親愛的會員", "text/html; charset=UTF-8");
 
            Transport transport = sessmail.getTransport("smtp");
            transport.connect("mail.****.com.tw","username","password");
            transport.sendMessage(msg, msg.getAllRecipients()); 
            transport.close(); 
 


reply to postreply to post
http://blog.yam.com/javanull/
作者 Re:javamail 收件人顯示的問題 [Re:chuang5089]
pclevin





發文: 322
積分: 0
於 2011-12-05 21:05 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1
 msg.setFrom(new InternetAddress("****.tw"));


改為
1
 msg.setFrom(new InternetAddress("****.tw", "你要顯示的名稱"));

還要加UnsupportedEncodingException
1
catch (UnsupportedEncodingException e)


試試看是不是你要的

api
http://javamail.kenai.com/nonav/javadocs/


reply to postreply to post
我的網誌
http://pclevin.blogspot.com
作者 Re:javamail 收件人顯示的問題 [Re:pclevin]
chuang5089





發文: 254
積分: 0
於 2011-12-06 15:49 user profilesend a private message to usersend email to chuang5089reply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
謝謝這就我要的輸出結果


1
msg.setFrom(new InternetAddress("****.tw", "你要顯示的名稱"));


reply to postreply to post
http://blog.yam.com/javanull/
» JWorld@TW »  Java SE 討論區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8