We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to remove alias name in email fields like From,To,CC & BCC

Hi Team,

Please suggest how to remove the alias name from the email fields like From, To, CC, BCC. Below is the scenario

From: “N V Phanikumar P” <nvphani@****.com>

We dont want the name infront of email id in all the email fields.

Please verify and suggest the same from your end.

Thanks
Phanikumar P
+91-9985079507

@nvphani,

Please use the code snippet given below to extract email addresses from email fields.

System.out.println(msg.getFrom().getAddress());
MailAddressCollection toAddressCollection = msg.getTo();
MailAddressCollection ccAddressCollection = msg.getCC();
MailAddressCollection bccAddressCollection = msg.getBcc();

for(MailAddress toAddress : toAddressCollection){
    System.out.println(toAddress.getAddress());
}
for(MailAddress ccAddress : ccAddressCollection){
    System.out.println(ccAddress.getAddress());
}
for(MailAddress bccAddress : bccAddressCollection){
    System.out.println(bccAddress.getAddress());
}

We hope that this answered your question. Please feel free to reach us if additional information is required.

Thanks for your reply Muhammad.

We are also using the same code snippet to get the email address only. But still we are getting alias name in From field.

Below is the code snippet for

String from = message.getFrom().getAddress();

Thanks
Phanikumar P
+91-9985079507

@nvphani,

Please test the code using the latest version of Aspose.Email for Java API. Please share the version of the API that you are using as well.