We are using the Single email message class to send emails on a forgot user name scenario. We want to change the from address display name to a valid name. I used the email.setSenderDisplayName method and override the name and still salesforce is overriding it with a custom name. How do we set the display name to a valid name? This is happening on a force.com site and for the guest user profile. I could not use the organization wide email address as salesforce does not show the guest user profile on the drop down.
here is the code
Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();
email.setReplyTo(fromaddress);
orgName = UserInfo.getOrganizationName();
email.setSenderDisplayName(orgName);
apexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'sender display name'+ String.valueOf(orgName ) ));
email.setToAddresses(new String[] { emailTo });
email.setSubject(subject);
email.setHtmlBody(htmlBody);
email.setPlainTextBody(plainBody);
Messaging.sendEmail(new Messaging.SingleEmailmessage[] {email});