Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [singleemailmessage]

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

1
vote
1answer
32 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
23 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
19 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
17 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
23 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
19 views

Single Email limit per execution using Apex Trigger

How many emails will be send using trigger per execution?
2
votes
1answer
49 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
24 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
28 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
68 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
32 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
20 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
52 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
209 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
35 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
27 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
77 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
122 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
28 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
34 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
15 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
58 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
140 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
43 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
63 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
73 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
21 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
46 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
394 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
28 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
39 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
91 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
104 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
391 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
70 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 ...
3
votes
1answer
121 views

How to Messaging.sendEmail() so that the email is properly shown on a record's activity tab in Lightning Experience?

This question is related to but different from How to use an Apex Email Service to store emails on a record EXACTLY as Salesforce does? I want to send an Email using Messaging.sendEmail() This Email ...
0
votes
0answers
24 views

Unable to update case comments from email message

In my organization we set up email-to-case. Now when they sent emails from sfdc I need to update case comments. I wrote a trigger on email message object and updating case comments. But the problem ...
0
votes
1answer
24 views

How can I report on Salesforce's 'External Email limit' for my specific organization?

I was looking at the Governor Limits page: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm And I wanted to see if we can see how close our org comes to ...
0
votes
1answer
79 views

How to Change Task subject name for mail.setSaveAsActivity(true);

I am sending a mail through batch class and i am setting mail.setSaveAsActivity(true); also. So the mail saving as an Activity history. Mail: As I am setting mail.setSaveAsActivity(true) Mail name ...
0
votes
1answer
148 views

singleemailmessage and activity

I have a controller that I am using to create an email from a template. The template pulls a custom object and sends an email to several people via to:, cc:, and bcc:. I added the settargetobjectid ...
0
votes
1answer
31 views

Sending email from Trigger Not working fine

I have created a trigger that is supposed to be sending emails to the contacts on their update, based on certain criteria. It works fine for individual records, but on bulk testing, it is sending all ...
0
votes
1answer
234 views

Single Email Limit Exceeded Error [duplicate]

while am executing this code am getting this error as single email limit exceeded. An Apex error occurred: System.EmailException: SendEmail failed. First exception on row 0; first error: ...
0
votes
1answer
64 views

Does creation/update of an EmailMessage record ever send an actual email?

I suspect the answer is no, that one would need to use an unrelated call such as sendEmail() or something like that to actually send a message. That said, I'm in the process of doing a data ...
0
votes
1answer
21 views

What is Pattern idPattern in inbound email service?

Can anyone explain what is Pattern idPattern and Matcher in the flowing class? I've seen in many classes with different patterns like Pattern idPattern = Pattern.compile('006[A-Za-z0-9]{12}'); and ...
0
votes
1answer
40 views

How to filter only last reply from total email thread

I have a requirement to update case comments based on email responses from Emailmessage. I created a trigger on email message working well.But, now it is creating case comments of an email with whole ...
0
votes
0answers
66 views

SingleEmailMessage Subject Issue in Sandbox [duplicate]

I am sending an email from Sandbox using apex code but email subject comes with some kind of ID. How to remove this ID and Sandbox . I have work around the email setting also but I could not find it. ...