function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashwani PradhanAshwani Pradhan 

Why display Name not showing up in email?

I am try below code and its not showing email display name, even its not showing full email address. Its just picking before the @ symbol like if my org wide address is asw_india_supp@gmail.com then in from it will come asw_india_supp

Here is my code peice 
Messaging.SingleEmailMessage singEmail = new Messaging.SingleEmailMessage ();
	String [] toAddresses = new list<string> {'ashwani.pradhan@test.com'};
	
	//Set recipient list
	DateTime d = DateTime.now() ;
	String dateStr =  d.format('MMM-dd-yyyy');
	// Use Organization Wide Address  
	for(OrgWideEmailAddress owa : [select Id, Address, DisplayName from OrgWideEmailAddress]) {
		if(owa.Address.contains('ir')) singEmail.setOrgWideEmailAddressId(owa.id); 
	}  

	singEmail.setToAddresses (toAddresses);
	singEmail.setSubject('Salesforce Contact Correspondence Details Report as of '+ dateStr);
	
	singEmail.setHtmlBody('Hello');

	Messaging.SendEmailResult [] r = Messaging.sendEmail (new Messaging.SingleEmailMessage [] {singEmail});
Please help..
 
Anupama SamantroyAnupama Samantroy
Hi Ashwani,

The Display name is just the name which will be shown in the recipients email.You can go through this link https://help.salesforce.com/apex/HTViewHelpDoc?id=orgwide_email.htm
Display Name is the word or phrase users who receive your email will see as the sender of the email.

Thanks
Anupama
VineetKumarVineetKumar
Try setting this attribute in the SingleEmailMessage
singEmail.setSenderDisplayName('<Name>');
Ashwani PradhanAshwani Pradhan
Hi Anupama, I know that! But my client want like this to show to recipients  Salesforce Support<asw_india_supp@gmail.com>, I guess this is because I am using an email group rather than a personal email in my org wide email.

Hi Vineet, We can not set display name if using setOrgWideEmailAddressId.

Thanks,
Ashwani
 
VineetKumarVineetKumar
Yes you are correct, it cannot be set if using setOrgWideEmailAddressId.
I just tested your code and I was able to see the name<emailaddress>
There maybe a chance of the group email causing the issue, but I personally think that shouldn't be the issue.
SandhyaSandhya (Salesforce Developers) 
Hi Ashwani Pradhan,

Even I tested your code for me name displays, but when I hover it shows complete email id.

Thanks and Regards
sandhya
Ashwani PradhanAshwani Pradhan
Yes it seems my email service provider overriding group email address and not showing like ABC <asw_india_supp@gmail.com>

Thanks guys for helping.