Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

USer Name  RSS feed

 
Raja Islam
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i am using this method to send email.it is working great.but i want to appear user name when mail receive.it currenly only show email addres of sender.which method should i use to get user name also.

public void sendMail(String mailServer,String subject,String to[],String from,String messageText) throws AddressException,MessagingException{
Properties mailProp=new Properties();
mailProp.put("mail.smtp.host",mailServer);
Session mailSession=Session.getDefaultInstance(mailProp,null);
int toCount=to.length;
InternetAddress[] toAddrs=new InternetAddress[toCount];
for(int i=0;i<toCount;i++) {
toAddrs=new InternetAddress(to);
}
InternetAddress fromAddr=new InternetAddress(from);
Message msg=new MimeMessage(mailSession);
msg.setFrom(fromAddr);
msg.setRecipients(Message.RecipientType.TO,toAddrs);
msg.setSubject(subject);
msg.setContent(messageText.toString(),"text/plain");
Transport.send(msg);
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!