I have created an LWC with a form by collecting the basic info, Then i will be sending the info to the email service.
Below is the code
string emailAddress = GetEmailServiceAddressUtility.getemailServiceAddress('Enrollment');
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
string[] to = new string[] {emailAddress};
email.setToAddresses(to);
email.setInReplyTo('[email protected]');
email.setSubject('New Enrollment' + ';' + formId);
email.setHtmlBody(strObject + '~~~~EnrollmentTermCondition~~~~' + term);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
This email is not received from the guest user, but when I tried from SYStem admin It worked.
tried the below code too
Messaging.SingleEmailMessage emailtest = new Messaging.SingleEmailMessage();
emailtest.setToAddresses(new String[] { '[email protected]' }); // Please add your email id here
emailtest.setSubject('my subject');
emailtest.setPlainTextBody('plain text body');
List<Messaging.SendEmailResult> results = Messaging.sendEmail(new Messaging.Email[] { emailtest });
if (results[0].success)
{
System.debug('The email was sent successfully.');
}
else
{
System.debug('The email failed to send: ' + results[0].errors[0].message);
}
In debug log I can see this 'The email was sent successfully.' message but email not received.
Note:
- Checked in Deliverability Access level set as ALL Email
- Send Email permission is enabled for Guest User.
Please let me know anything which I am missing here.
R
in theMail Event
column