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
1answer
23 views

How to Display Case Number on automatic email response with Email-to-Case

I am trying to include Case Number of an email template for an email-to-case. Basically, when a client sent an email to a closed case, he received an automatic email reply. I would like the automatic ...
0
votes
0answers
13 views

Testing schedulable apex class that sends an email [duplicate]

I am relatively new to Salesforce development (I'm an intern) and I am currently struggling with achieving 75% code coverage when testing a class that regularly sends out an email. I have included the ...
1
vote
1answer
55 views

Code optimisation on EmailMessage

I have created a class and a trigger to be able to stop clients from sending email message on Closed Cases. The code works as intended. We tend to communicate with Clients using the quick action Email ...
0
votes
0answers
17 views

File Corrupt error in Excel using Reports as attachments in Apex

As title suggests i am using converting reports as attachment in Apex and sending as Email to users. The excel file is in .XLSX format when i tried to open the file i am getting file corrupt error. ...
0
votes
1answer
28 views

Mail not received - SingleEmailMessage()

I am working in Visual studio code. On the click of a lightning:button, I am calling a javascript method, inside the method I am calling a visual force page using window.open(url), submiting the form ...
0
votes
1answer
56 views

Batch apex finish method emails firing multiple times [duplicate]

I have configured finish method to send error files on csv upload. It works ok for 200 records but if the sheet exceeds records more than 200 say 2000 I am getting emails for every job that has ...
0
votes
1answer
33 views

How to cover catch block in Messaging.SingleEmailMessage

I have a class that sends an email notification when a partner user posts in Chatter Feed. I wrote a test class which already covers most but I'm just having some difficulty here figuring out how to ...
0
votes
1answer
27 views

How to Link to a record in Lightning using Apex

I am sending an email notification to internal users from the community through Apex SingleEmailMessage when a partner user posts in Chatter Feed. I wanted to add a link to the Opportunity record into ...
1
vote
0answers
40 views

Messaging.renderStoredEmailTemplate() is rendering Visualforce email template without custom header

Messaging.renderStoredEmailTemplate() is rendering Visualforce email template without custom header. I have a requirement to send an email with custom header. So created a visualforce email template ...
0
votes
0answers
12 views

Why mail is not working after installing app to another org?

In my app, I have a feature which sends emials to leads. This is the code I used: Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage(); message.toAddresses = new String[] { ...
1
vote
0answers
19 views

Messaging.SingleEmailMessage with Template fails, but Messaging.renderStoredEmailTemplate() works?

I'm sending out a singleEmailMessage using a template. The Messaging.SendEmailResult reports success and the email comes through, but the template portion of the email is empty. (The WhatId is ...
0
votes
2answers
62 views

Email Limit Exceeded on Batch Apex

I have a batch job which sends email notification in bulk using Messaging.sendEmail() and its using setTargetObjectId to set the reciepient. It sends out thousands of emails but one day I got case ...
0
votes
0answers
9 views

Empty Attachment related list in the Email Activity History when sending Outbound Email Message

We are sending an email using Messaging.SingleEmailMessage. When sending an email, the email body text and the attachment successfully sent to the Email inbox. But when I go into the activity history ...
0
votes
0answers
24 views

First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY - SendEmail failed

sending Email from Public page Site, Getting following error, It was working earlier, not sure suddenly getting this Error in LOG common.apex.methods.MessagingStaticMethods$EmailExecutionException: ...
0
votes
0answers
12 views

How many emails or SingleEmailMessages can be sent as part of a single sendEmail method invocation? [duplicate]

I see the governor limits for maximum no. of sendEmail invocations per transaction as 10 in this article https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm#...
0
votes
0answers
29 views

SendEmail does not save activity - INVALID_ID_FIELD, SaveAsActivity is not allowed with whatId that is not supported as a task whatId

I am sending an email using batch class and want to save it as activity. But getting following error: INVALID_ID_FIELD, SaveAsActivity is not allowed with whatId that is not supported as a task whatId....
0
votes
0answers
40 views

Can we save attachment in activity using apex

I'm using an apex single email message to send an email with an attachment. Everything is working fine. But in the activity history, I can only see email body details but attachment not saved in ...
0
votes
0answers
35 views

writing css in apex class

I have an issue which I need to send email from Apex, the email can be received in Gmail or Outlook emails. I need to style the context and I'm using inline CSS in my HTML tags. The issue is that ...
1
vote
1answer
33 views

stop email to be sent via apex

I have a Batch process which sends an email in the finish method. I tried to check some records that failed via this process and since My JSON contains thousands of records, I decided to replace this ...
0
votes
0answers
31 views

How to display continuation of task records sent from SingleEmailMessage using apex html

How to display continuation of task records sent from SingleemailMessage using apex html. I have sent email with task records using batch in html table, need to send 50 tas records per email but need ...
1
vote
3answers
161 views

Customize send time according to timezone

How we can send one single email to multiple customers based on their timezone. Let's suppose we have 10 US customers and as we have different timezones in every state. We have to customise email in ...
0
votes
1answer
125 views

How to use Messaging.SingleEmailMessage to force stop sending emails to email addresses that no longer exist / email server problem

So I have created a button on a Visualforce page to call the controller to send an email like so. It works perfectly for valid emails but little did I know the hell that came when I sending it to ...
0
votes
2answers
68 views

Creating an invocable apex class sending email with optional send from

I am trying to set up an invocable apex class to send an email to a contact with merge fields from other record ID types with an optional variable to set the sender. I have looked at this question for ...
0
votes
2answers
32 views

System.LimitException: Too many Email Invocations: 11

// Original Code for(Account obj :updateAsDuplicate){ obj.Duplicate__c = true; for(String oldStr : hasExternalIdOldSet){ if(obj.Id.equals(duplicateMap.get(oldStr))){ ...
0
votes
1answer
72 views

How to send email with new lines in apex?

In my app, there is a lightning:textarea in which the user can type the content that will be send as an email to the users. This is the textarea: As you can see from the image, the 'Thanks' is after ...
0
votes
0answers
12 views

EmailMessaging wont display the merge fields during the batchprocess

We have created a batchclass to send pending opportunity approval remainder email for the approvers as the flow we are sending email and referred a email template ID in which I have used merge fields ...
0
votes
1answer
29 views

Why is Primary Contact for Org Getting Added to SingleEmailMessage()?

Here is a method that fires when a guest enters their name and email address into a visualforce page and clicks submit. The email is being sent fine, but the primary contact on the org is also getting ...
0
votes
2answers
36 views

First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY

I have Visualforce email template which has recipientType="User" relatedToType="Enrollment__c" Getting Following error 11:53:56.0 (361868475)|EXCEPTION_THROWN|[109]|System.EmailException: SendEmail ...
0
votes
1answer
119 views

Prevent file from being duplicated as email attachment - Apex

I've button when i click on it it generates new file , i want to attach that file to email The problem i'm facing is that i found duplicate attachments when i click on button twice , 3 attached file ...
0
votes
1answer
58 views

how to remove unwanted things from mail sent from salesforce?

I wanted to send an email from my Apex class, and I used the following code: Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage(); message.toAddresses = new String[] { emailId }; ...
1
vote
1answer
90 views

SendEmail failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY

I have custom LWC page as Public Site, In my Page i will be collecting the Name and Email address, On clicking send will insert the data in Custom Object and will send an Email to an given Email ...
0
votes
0answers
24 views

Pre Populating Body and Subject from Email Template into Subject and Body using aura components

I am a beginner in lightning components. I have a requirement to preview an email before sending it to users, contacts through Lightning aura components.I have an email template which i want to get ...
0
votes
0answers
94 views

System.UnexpectedException: Programmer error: cannot rollback to savepoint on another transaction

I am trying to send an email using the Visualforce template. VF Template <messaging:emailTemplate subject="Lead Score Card" recipientType="User"> <messaging:htmlEmailBody > <c:...
1
vote
0answers
25 views

How to send decrpy of field value in Single Email Message [duplicate]

I have a input form in LWC(It's a salesforce Public Site). Once the Form submitted by the user , we will generate the Random Password and send Email to User with username and password using Email ...
0
votes
0answers
86 views

Messaging.SingleEmailMessaging Sends duplicate emails to recipient

I am trying to send Krow expense list files to an email address. I have that functionality working, however it does send duplicate emails. I have added a debug message just before the sendEmail method ...
0
votes
0answers
180 views

SingleEmailMessage From APEX

Sending An email from Apex code. I have LWC button in Custom object, On clicking the button will call the APEX method by passing recordId and get the email address from the same record and send Email. ...
0
votes
1answer
132 views

Sending a Email Template from APEX

I'm attempting send a Text email from Apex code, Email is sending without body. I have created a new LWC button and Placed in custom Object Detailed page. On Clicking of the button this Apex method ...
0
votes
1answer
21 views

How to edit the visualforce email template properties in Apex controller

How to update the apex:dataTable used in the visualforce email template, when editing the properties of the visualforce template from Apex. I am able to query the markup from email template ...
1
vote
1answer
174 views

In Messaging.SendEmailResult what does the errors attribute contain?

I'm sending multiple emails using Messaging.sendEmail. After that I'm checking for the results by looping over the List<Messaging.SendEmailResult> just like the example below. Now my question is:...
1
vote
1answer
46 views

Help required with an Apex class that sends email

I am new to salesforce. I am practicing triggers. As a part of my learning, I wanted to send an email to the opportunity owner when an Opportunity is modified. I wrote a trigger on Opportunity and ...
1
vote
0answers
389 views

Email Message record creation through process builder

I want to create an email message record after sending an email template. Is there any way to create email message record through process builder or workflow after sending an email alert. So that we ...
-2
votes
1answer
49 views

Org wide address isnot properly in the From address of the mail

After receiving mail still it shows FROM address is "my email address(EG:****@gmail.com)" instead of org wide Email address. Trying to set Like below: From address=Org wide email Address, ...
-1
votes
1answer
58 views

Single Email Message isnot triggering

I have created following Template (Visualforce Page Template):GDPR_Subscriber_Notification If I do send Test and verify Merge fields option,Its working as expected <messaging:emailTemplate ...
0
votes
1answer
50 views

Outbound Email and Add Error are not working together

Actually i want to send email whenever duplicate record will create in salesforce and also show the error "Duplicate Account found" . I'm using for sending email through Outbound Email for salesforce ...
0
votes
2answers
443 views

sObject type 'SalesforceIqUser' is not supported

So I am trying to send out an email in the system and I am getting this error but I am at a loss. Everything that I am seeing has issues internally where you have to reach out to salesforce to have ...
0
votes
1answer
76 views

getting error while using SendEmail in batch class

I'm trying to send email to list of users using batch class, but its throwing below error for few records. Error: System.EmailException: SendEmail failed. First exception on row 0; first error: ...
2
votes
1answer
54 views

Visualforce as PDF error

I am creating a VF page where I have to select date and filter data and using button I need to send the another VF page as PDF with same data in email as attachment. When I selecting Date from 1st VF ...
0
votes
1answer
80 views

How do I test a schedulable email sending?

I have a schedulable apex class for the email sending. I tested a schedule, but I can't to coverage sending logic. Is there a some way to test good and bad scenarios for it? My class: public class ...
-2
votes
1answer
40 views

Salesforce Messaging.SingleEmailMessage Test Class

Can anyone help me get test coverage for Messaging.SingleEmailMessage? I'm using email template. Whenever a Case closes, it should send email to Contact.Email and bcc emails of the custom label. How ...
0
votes
1answer
240 views

Messaging.SingleEmailMessage email fails with invalid email address when using Target Object Id

I have a custom object that allows my users to create series of emails to their clients. I have a scheduled Apex job running hourly that scans for emails that are schedule to go out, creates the ...

1
2 3 4 5 6