• Post Reply Bookmark Topic Watch Topic
  • New Topic

change email format from abc@bla.com to a name  RSS feed

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I wonder if someone can help me on this minor issue. I am using the JavaMail API and everything works great. the thing is that the mail shows up as: vzee993@verizon.net

My question is: how can I change this FORMAT to somthing like: "Auto Message" (convert from the actual email xxx&xxx.xxx to a name)

Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the name in quotes, that should work. e.g.:

[ November 02, 2004: Message edited by: Paul Sturrock ]
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mmmm,

my code looks like this:

String from=vzeek34@verizon.net;

Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));

If I'm changin the 'from' to "AUTO MESSAGE" - it throws an excp.

I tried your solution but it didn't work.

InternetAddress addr = new InternetAddress("\"Auto Message\"");
Message msg = new MimeMessage(session);
msg.setFrom(addr);

any suggestions?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I tried your solution but it didn't work

Did you? Well, the quoted string "AUTO MESSAGE" is very definately an RFC822 compliant address, so creating an new InternetAddress object with it will not throw an exception.
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank Paul

I'm not looking for a qouted name, i just want it to appear as a name. maybe I
am a bit ambiguous, so let me revise:

the result on my outlook looks like this:
(LOOK AT THE 3RD LINE)


From subject Date
Mike Shomer bla bla November 2
Dan Phillips bla bla November 2
vzekkk@verizon.net udpate November 2

and I would like to change it to:



From subject Date
Mike Shomer bla bla November 2
Dan Phillips bla bla November 2
AUTO MESSAGE udpate November 2
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just turn off strict RFC822 parsing:

But you'll be moving away from the standard if you do - so you may well generate problems for yourself if your SMTP server ever changes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!