Questions tagged [singleemailmessage]

Relates to the SingleEmailMessge class, which provides methods for sending single email messages through apex.

Filter by
Sorted by
Tagged with
0
votes
2answers
29 views

How to test and assert email template?

I'm getting this error: System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-...
0
votes
0answers
11 views

VF Email template - send different bodies to same person

I have a batch which I use to send emails to contacts - the emails are Messages about courses - so Each Contact should have the same email template repeatable with a different body. So, I created a ...
0
votes
0answers
17 views

Respond to a thread email via Apex [on hold]

Suppose that I send the email "This is the first email" from address "johnmith@gmail.com" and I generate a case with Email-to-case or a custom Email Service. If I later respond to this email from ...
1
vote
0answers
15 views

Email Relaying Not Working When email is sent from Apex

Our application has a few features where we allow the user to generate documents and send emails. This is all custom lightning components and apex code. We send the emails using SingleEmailMessage. ...
0
votes
0answers
26 views

Email Limit on Scratch Org?

Working in SFDX with a scratch org. I'm setting up a future method to send an email if it fails, trying to get the formatting right, and testing. Now, I've hit a wall: SINGLE_EMAIL_LIMIT_EXCEEDED, ...
0
votes
0answers
19 views

Messaging.SingleEmailMessage translated labels

I have a batch that sends an article through email to contacts. I have a field in the Article Object which indicates the lang of the article. I'm using Messaging.SingleEmailMessage and I have ...
0
votes
0answers
27 views

Send email with different language via Apex

I have a batch process which I'm creating Emails without a template - with HTML Body - which there I should style the emails and send them to the contacts. The emails are built in a way which I go ...
0
votes
0answers
31 views

SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, DML currently not allowed: []

Need some help in understanding error , SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, DML currently not allowed: [] . I get this error when calling send email method ...
0
votes
0answers
11 views

View the history of SingleEmailMessage usage

I know how to see how many SingleEmailMessages we've sent in the current GMT day, but I need to know if it's possible to see a history of emails further back than that. For example, for the past week, ...
0
votes
0answers
24 views

Attachments are not visible if setWhatId is not defined while email from Apex

I am sending email to selected Contacts (Custom Component) via Apex. User will also be attaching multiple files to the email. If setWhatId(setting it to Case) is defined, EmailMessage Activity shows ...
0
votes
1answer
20 views

user merge fields doesn't replace by user record ID

I am trying to send email through email template to user but It is always replacing the user merge fields by org admin's user name instead of targetobjectID user. Org admin : luke wright Email ...
1
vote
1answer
58 views

SendEmail Method results in EmailMessage Object in Sandbox - Does not in Production

I am using the following logic to send emails. Enhanced email is activated on both orgs and so is Email-to-case. In the sandbox (Summer '19), executing this method results in an email message ...
0
votes
0answers
28 views

Community Profile User unable to send APEX emails

I have a class containing this method that creates an email in APEX and sends it out once the method is called. public static void generateMessagingTemplates( String requestLogId){ String ...
0
votes
0answers
29 views

The content that i received through mail as a pdf attachment is partial of the actual content sent

public static String AcceptTnC(String contractInfo2){ system.debug('contractId2'+contractInfo2); Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage(); Messaging....
0
votes
0answers
21 views

ReRendering Output Panel with MHTML String Fails

I am rerendering EmailMessage HTML Bodies onto visualforce pages. For most emails this is not a problem, however for one email the rerender never completes. Research into this suggests some sort of ...
0
votes
0answers
29 views

PDF Generation: Classic Email Template Content is counted in Salesforce Apex Code Limit?

We need to send PDF based on salesforce record. For this we have used Classic Email Template and Messaging.Singleemailmessage class to send PDF as attachment. We have used custom template for ...
0
votes
1answer
21 views

Single Email limit per execution using Apex Trigger

How many emails will be send using trigger per execution?
2
votes
1answer
95 views

Invalid Message Id Reference - In-Reply-To Header is Not Valid

I am designing a custom mail application with Visualforce and Apex in salesforce and I'm running into some issues maintaining threads and setting reply to ids. To establish which emails are a ...
0
votes
0answers
29 views

HTML Email Status won't get created if setWhatId() for Messaging.SingleEmailMessage is specified

In my org I've set up an automatic process that sends email messages with the Custom template (with the HTML) to the contact. It has triggered similar code: OrgWideEmailAddress addr = [select Id from ...
2
votes
1answer
38 views

Error when using setOrgWideEmailAddressId in SingleEmailMessage [resolved]

I'm trying using setOrgWideEmailAddressId in my class Apex but he return this error: 718403274-125341 (195485361) Code: @AuraEnabled public static void sendEmailReference(String strEmail){ ...
1
vote
1answer
155 views

Test class Limits.getEmailInvocations() showing zero and assertion is failing

I have a bizarre issue. I have a trigger that will send an email based upon a record update. When I debug my trigger running the test class it showing the email result as success and when I debug and ...
0
votes
1answer
17 views

Using SingleEmailMessage to send email with template to an email that might or might not be a contact

Normally to send an email with a template this is how you would do it. Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setTargetObjectId(contact); mail....
0
votes
1answer
41 views

MIXED_DML error only on UpsertResult has errors

In a @Future method (because of other MIXED_DML problems) we are upserting users and collecting the results. We then want to send an email once the transaction is complete. If everything works well, ...
0
votes
1answer
21 views

Email sent from Lead is counting under daily limit

I was going through the salesforce document Daily Allocations for Email Alerts It is mentioned that There’s no limit on sending single emails to contacts, leads, person accounts, and users in your org ...
0
votes
2answers
56 views

notify user by sending an email to user whose last-login is more than 1 day

Here is my code, please check global class LastLoginEmail implements Schedulable { global void execute(SchedulableContext SC) { List<User> uds =[SELECT Id, LastLoginDate, Email FROM ...
0
votes
1answer
406 views

SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, java.lang.NullPointerException: []

I am getting this error message: Message: SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, java.lang.NullPointerException: [] Stack Trace: Class.MessagingHelper.send: ...
1
vote
0answers
65 views

Messaging sendEmail Issue

I'm using a single email message to send an email. When we tried to sent an email with a wrong email address on newly created lead record. I'm getting message result success is true. But the same ...
0
votes
2answers
30 views

Add bccAddresses to SingleEmailMessage

I'm trying to send an email and to add some bcc addresses to it. I don't get an error, I even get the debug statement: "The 1st email was sent successfully." and the email is sent to the email main ...
0
votes
1answer
133 views

Set ParentId on SingleEmailMessage

I reviewed the documentation for the SingleEmailMessage but haven't found how to add the parentId (i.e. case Id) to the email message, is this even possible? I want to be able to see the email on the ...
0
votes
1answer
26 views

HTML link attachments and a bash script to download them all

As the title implies. I'm looking for a bash script that will iterate over html files in a folder and download the files to the same folder. I'm hoping someone in here has run into this before and hs ...
0
votes
1answer
188 views

Outbound email message with attachments limit

I am using Apex to send emails with attachments to users (with SingleEmailMessage to be more precisely). From some MB (I Don't sure exactly the size - because it changed from time to time when I try ...
0
votes
0answers
43 views

Exporting attachments via contentType results in some .pdf coming through as .url or .html

As the title implies. Here is the code. List<Messaging.SingleEmailMessage> attachmentEmails = new List<Messaging.SingleEmailMessage>(); Map<Id, Case> caseMap = new Map<Id, ...
0
votes
1answer
41 views

How to test email notification to the Administrator?

I can't insert right profile to test user like an administrator and don't know how to test it right. Help me please. public void notifyAdministrator(String errorException){ User user = [SELECT ...
0
votes
1answer
20 views

Send email with multiple bodies

I have two custom objects: Parent__c and Student__c with Master-detail relationship. Parent__c object has Email__c field. I need to send email to Parent__c with link(s) to Student__c object(s). I have ...
0
votes
1answer
23 views

Is there a certain way you need to call targetObjectId?

So normally I would send an email by normal means and without code but I need to do a query on our Team__c object to find out who I would need to send it to. I am trying to send an email to any "squad"...
1
vote
0answers
74 views

Understanding EmailMessage for Data Migration

As I attempt data migration from one Salesforce org to another, I am finding EmailMessage to be a very unnecessarily complicated object to understand. At one point I thought I understood that recent ...
2
votes
1answer
187 views

Messaging.SendEmailResult Type cannot be constructed?

I'm trying to create a simple mock of messaging Messaging.sendEmail and in my code I'm trying to do the following to construct mocked instances of Messaging.SendEmailResult Messaging.SendEmailResult ...
0
votes
1answer
54 views

Testing/Mocking design pattern to test Messaging.SendEmailResult

I have some code in an After Insert trigger that does some conditional DML updates to the records being inserted if a mail is successfully sent out. I'm looking for a solid, modular way to test this, ...
1
vote
1answer
100 views

SingleEmailMessage issue

Could someone look into this code, and let me know if they see anything wrong that may be causing a problem? For some reason my email is being successfully send with HTML version, but the text version ...
0
votes
1answer
14 views

Sending Single Email from public visualforce

I am trying to send an email from a public visualforce. I think it isnt working because some permissions of the public profile because I tested the method from developer console and it worked ...
1
vote
1answer
80 views

pdf is generating as invalid format

I have the following function which generated an email based on a template passed. The function is triggered from a rest api. public static Messaging.SingleEmailMessage singleMessageHelper( ...
0
votes
0answers
27 views

Not able to send the emails

I am using the below code in execute anonymous window. when I execute the same in the dev org it works as expected but when I run this in production or in the sandbox I get the Email sent successfully ...
2
votes
1answer
59 views

Set Organization wide email as TO address for SingleEmailMessage

I want to use an organization wide email address as both to and from address (to send notifications to an email alias). Method setOrgWideEmailAddressId(emailAddressId) only sets from address. I can ...
5
votes
2answers
573 views

For the Platform Event “Automated Process” user, why do both Visualforce controller access and email sending fail?

We are executing some asynchronous code that uses getContentAsPdf on a Visualforce page as the result of handling custom platform event and we get this error in the Apex Jobs listing: First error: [...
1
vote
0answers
33 views

Salesforce Contact Opt out (Messaging.SingleEmailMessage.setOptOutPolicy) is not working for User's ID

I am trying to use salesforce opt-out feature via APEX code. According to the doc, Salesforce should respect the opt-out field of contact if we use the ID of an object as a target. When I am using ...
0
votes
1answer
45 views

Batch sending out mass email to all

I have a batch which after creation of records send out emails to the opportunity Account manager for which new record is created. // Get All Opportunities set<id> Billoppid= new set<id&...
2
votes
1answer
116 views

Unexpected token and invalid loop variable

I'm new to development and trying to edit a trigger handler class for the account. At the moment we only need anything triggered after update I believe. This is what the class looks like at the moment,...
0
votes
1answer
157 views

Passing List of emails in Chunk as Toaddress in SingleEmail message

Can you Try to help me how to pass list of Toaddress in Single email messages as a chunck as per the salesforce documentation we can set 100 Toaddress but in my requirement i have more than 300 mails ...
7
votes
1answer
486 views

How to get the Id of an EmailMessage after sending a SingleEmailMessage with Messaging.SendEmail()?

Is there any way to easily retrieve the Id of EmailMessage records after sending them via Messaging.SendEmail()? Messaging.SingleEmailMessage m = new Messaging.SingleEmailMessage(); m.setToAddresses( ...
0
votes
2answers
99 views

ASK - Field value is blank in Apex single email (HTML Template)

My case is i want to send email with attachment in custom object using single email message using HTML Email Template (with letterhead). Current condition i successed to make the email same like ...