+ Start a Discussion
rupesh ranjanrupesh ranjan 

How to set authentication for other SMTP in this mail code

How to set authentication for other SMTP in this mail code
 
public pageReference send(){
	Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();  
	List<String> ccAddresses =new List<String>();  
	if (AddRecep != '' && AddRecep != null) 
	{
		ccAddresses  = AddRecep.split(';');
		email.setTargetObjectId(conId);
		email.setCcAddresses(ccAddresses);
		email.setSubject(subject);
		email.setHtmlBody(body);   	
	    for(OrgWideEmailAddress owa : [select id, Address, DisplayName from OrgWideEmailAddress])
		{
			if(owa.DisplayName.contains('System Admin'))
			{
				email.setOrgWideEmailAddressId(owa.id);
			}
		}
		Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});  
		for ( Messaging.sendEmailResult result : res ) {
			if ( !res[0].isSuccess () ) {
				System.debug ( result  );
			}          
		}       
	}  
	return null;        
}