I am implementing a requirement in Service Cloud to track incoming and outgoing emails for some Purchase order Custom object. Within this we have to group some records and send email alert to customers. The requirement is to select some records from the listview and send One email towards To,Cc and Bcc, along with the functionality to attach some files. I know we can implement this using a lightning component and apex class. But, since each email address in the Messaging.SingleEmail will be counted as one api call and we have many more resources using SingleEmail method in production, this will hit Org wide limit of maximum 5000 Messaging.SingleEmail calls made in 24hrs. I have checked that these kind of limit doesn't apply for Workflow Alerts or Flows but neither of them have the ability add email recipients in Cc, Bcc or attach files from Content Document dynamically. Can anyone suggest a better way to implement this without touching any apex Email Method. Thanks in advance
122485
I have been looking for some time looking for a way how can error SINGLE_EMAIL_LIMIT_EXCEEDED Email limit exceeded be avoided if I need to send one simple email to one single user, for example, myself.  15 Email invocations limit on Developer Edition is a very small number, and it is usually quickly exceeded. Using Workflow Email Alerts may help to send more emails but still it is limited.
39333
I have written a trigger to send email. Whenever the trigger is fired i am getting equal no of mails which is equal to no of records retrieved.  Ex - If i am getting 3 records, three times i am receiving email. Can anybody tell me where i am going wrong -  trigger taskEmail on Project__c (after update ) {     set&lt;String&gt; projName = new set&lt;String&gt;();     list&lt;Task__c&gt; listTask = new list&lt;Task__c&gt;();      for(Project__c pro : Trigger.new) {         projName.add(pro.Name);     }      listTask = [SELECT Id,Project_Approval__c,Project_Name__c,Status__c,Task_Executioner__c FROM Task__c WHERE Project_Name__c IN : projName];     system.debug('11111' + listTask.size());     EmailTemplate et=[Select id from EmailTemplate where name='Multiple Tasks'];     List&lt;Messaging.SingleEmailMessage&gt; mails = new List&lt;Messaging.SingleEmailMessage&gt;();      if(listTask.size() &gt; 0) {     system.debug('222222' + listTask.size());         for(Task__c con : listTask ) {         system.debug('33333  enter for ');                if(con.Project_Approval__c =='Approved' &amp;&amp; con.Status__c == 'Open'){             system.debug('444   enter if inside for ');              Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();             mail.setTargetObjectId(con.Task_Executioner__c);             mail.setTemplateId(et.Id);             mail.setSaveAsActivity(false);             mail.setWhatId(con.Id);             mails.add(mail);         }         system.debug('0000000');      }      Messaging.sendEmail(mails); } }
56738
In Field Service Lightning I have a Trigger on ServiceReport which sends an email with attachment coming from ContentVersion.   This is the Test class I have written.  @isTest  private class testCreateServiceReport{       static testMethod void validateWO() {       WorkOrder wo = new WorkOrder();       wo.subject = 'Testing';       insert wo;       ServiceAppointment sa = new ServiceAppointment();       sa.ParentRecordId = wo.Id;       sa.EarliestStartTime = DateTime.now();       sa.DueDate = DateTime.now();       insert sa;       List&lt;ServiceReportLayout&gt; srl = [Select Id FROM ServiceReportLayout];       ServiceReport sr = new ServiceReport();       sr.ParentId = sa.Id;       sr.Template = srl[0].Id; //Need to check if there is a way to avoid srl[0] notation       insert sr; //If I comment this the text result is pass. When I enable it I get too see the below mentioned error.  }  }   This is the error Methods defined as TestMethod do not support Web service callouts I know that we need to write Test Classes for code that involves web service callouts using setMock() but I dont understand in what way inserting ServiceReport is related to making a callout.  Any help on this will be really helpful.
82427
I have created a picklist with selectOptions as Org-wide email address as below  VF Code  &lt;apex:selectList value="{!emailFromAddress}" size="1" multiselect="false"&gt;               &lt;apex:selectOptions value="{!OrgWideEmailAddress}"&gt;&lt;/apex:selectOptions&gt; &lt;/apex:selectList&gt;   Controller Code  public List&lt;selectoption&gt; getOrgWideEmailAddress(){         List&lt;SelectOption&gt; lstEmailIds = new List&lt;SelectOption&gt;();          // Use Organization Wide Address         for(OrgWideEmailAddress owa : [select id, Address from OrgWideEmailAddress]) {            lstEmailIds.add(new SelectOption(owa.id,owa.address));         }        return lstEmailIds;     }   The selected email Address Id is used to set as OrgWideEmailId for an email as below  Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage(); mail.setOrgWideEmailAddressId(emailFromAddress);   But when i select a Non verified email address then email sending fails. Hence i want a way to filter &amp; get only verified email address to show in Picklist options.  Tia.
23293
I want to create a case which has an attachment, Billing Account, and topics. Given below is the code from my Test Class:  Scenario: Once user submit the case request and ask for approval. The request goes to the Manager for approval, once the request approves, an email goes to Legal team with an Case attachments in an email.  Topic__c tc = new Topic__c(Name ='My New topic'); Attachment att = new Attachment(Name = 'sample.pdf');  Case c = new Case(Origin = 'Phone',                           Subject = 'New Testing',                           Department__c = 'XXXXXXX', Priority = 'Normal',                           Topic__c = tc.Id,                           Risk_Approval__c = true); insert c;   I am getting the below error:     System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CaseTrigger: execution of BeforeInsert   My Trigger class:  trigger sendEAttachmentsInMail on Case (before insert, before update){  for(Case casevar : Trigger.new){          Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();          mail.setBccSender(false);         mail.setUseSignature(false);         mail.setTargetObjectId(casevar.Id);         mail.setTemplateId('XXXXXXXXX');         mail.saveAsActivity = false;        //Set email file attachments         List&lt;Messaging.Emailfileattachment&gt; fileAttachments = new List&lt;Messaging.Emailfileattachment&gt;();         for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :casevar.Id])         {         // Add to attachment file list         Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();         efa.setFileName(a.Name);         efa.setBody(a.Body);         fileAttachments.add(efa);         }         mail.setFileAttachments(fileAttachments);       //Send email         Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });          } }
79257
I am struggling to set the sender address when sending a simple email using the Flow's core email action.  No matter what I put in the sender address field, the running user's email (my email) appears as the sender.
19184
I need to send dynamic email to all my booking contacts using AMP Script. Using FOR loop makes repetitive content. I am pulling contacts from Salesforce reports directly without using Salesforce Data Extension.  1) Any way to display content respective to each record (Dynamically)  2) Can we directly get Opportunity columns present in  SF reports to Normal Data Extension? Like we can do for Contact,Account &amp; Leads  3) Any way to uniquely identify each opportunity records?  AMP Script:  %%[ Var@fname,@AccountName,@PictureDay,@AccountPhone,@BookingOwner,@BookingOwnerEmail,@bookingdetail,@Accountid Set @Accountid = AccountId Set @fname=FirstName Set @AccountName=AccountName Set @AccountPhone=Account:Phone Set @bookingdetail = RetrieveSalesforceObjects("Opportunity","Picture_Day__c,OwnerName__c,OwnerEmail__c","Picture_Day__c","=","2016-06-25","CloseDate","!=","2015-10-03") For @i=1 TO RowCount(@bookingdetail) DO Set @limitRow = Row(@bookingdetail, @i) Set @PictureDay = Field(@limitRow,'Picture_Day__c') Set @Bookingowner = Field(@limitRow,'OwnerName__c') Set @BookingOwnerEmail = Field (@limitRow,'OwnerEmail__c') ]%%  Dear %%=v(@fname)=%%,  We are looking forward to taking photographs at %%=v(@AccountName)=%% on %%=v(@PictureDay)=%%.The phone number we have on file for you is %%=v(@AccountPhone)=%%.  Your Account Manager is %%=v(@Bookingowner)=%% and you can reach them at %%=v(@BookingOwnerEmail)=%%. %%[NEXT @i]%%   Thanks,  Mitesh
109985
Hope someone has an answer for my question. We have two business units in Marketing Cloud and one Salesforce Org. With the MC Connector, we push the SF data to MC.   At moment we use an SQL query to transfer the data of the synchronized objects from the parent business unit to the child business unit.The total sync time for the child BU is +/- 1,5 hour.  Cloud we use multi org to set up the MC connector for the child BU?   Thanks in advance,   Klaas
37194
I am trying to do an export of approx 30,000 attachments in our Salesforce Org,  Would anyone have been through a similar exercise and can advise best practice or the best way / tool to do this?  Kind Regards  matt
74058
Currently, we use Subscriber key= Email Address = Contact Key; We are planning to use Salesforce Contact ID as Subscriber key/ContactKey. Is there a way to mass update Subscriber key value for all our current Subscribers (we have around 250k subscribers)? Also, will we lose all the tracking data about our subscribers? We are mostly concerned about Einstein Optimization data, but we are not sure if Einstein tracks and stores the data based on the Subscriber Key or email address?
59454
I have a lot of mail traffic on my phone. But I want to be notified only for mail from certain contacts like my family, colleagues/boss, critical automated systems or at least any contact in my phone contact list (with email typed in).  Are there such applications which can access email on my personal/corporate server? Standard IMAP (or at least POP3) + SMTP, not some proprietary protocols like Exchange/Gmail.
59893
I'm creating a custom list for a helpdesk app.  I want the user to fill out a form in sharepoint (2010) and add attachments from screenshots, etc.  The workflow should send an email to our helpdesk system with the files attached.  Using sharepoint designer, i can only say yes there is an attachment, but i can't seem to attach the file to the email.  Any suggestions?
78453
I have been watching how to implement the batch for sending more than 10 email but I get errors. When I send emails I have a limit 5 and also are sent several times to the same user email  global class SendBatchClass implements Database.Batchable&lt;sObject&gt;, Database.AllowsCallouts{     String query = '';      global Batchname(){     }     global SendBatchClass(String newBodyBatch,...){        this.body = newBodyBatch;        try{...}        catch(){...}     }     global Database.QueryLocator start(Database.BatchableContext BC) {          return Database.getQueryLocator(query);     }     global void execute(Database.BatchableContext BC, List&lt;Contact&gt; scope) {         SES sesEmail = new SES(as3.key,as3.secret);         for(sObject s: scope){             sesEmail.sendEmail(subRecipients,sender,subject,newBody);         }     }     global void finish(Database.BatchableContext BC) {      } }
109679
I have the following code:      public class OrderRequestCreationEmails {     public static void sendMail()     {          Messaging.reserveSingleEmailCapacity(2);         Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();         String[] toAddresses = new String[] {'dgriff@varonis.com'};           mail.setToAddresses(toAddresses);          mail.setReplyTo('dgriff@varonis.com');          mail.setSenderDisplayName('Mail Test');          mail.setSubject('Success! Mail Sent');          mail.setBccSender(false);         mail.setPlainTextBody('BODY');          Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });     } }   I tried to call this function from a test as such: (I know its not an actual test, its just to see if I receive a mail).  @isTest private class CreationEmailsTest {     @isTest private static void sendMailTest() {         OrderRequestCreationEmails.sendMail();     } }   And I haven't received the mail, no idea why?  It's an example I took from the salesforce developer guide. couldn't find any answers online...  FYI - deliverability in the sandbox is turned on, and test deliverability works
61579
We are creating custom IDs for Accounts by incrementing an integer field in a custom class. The issue is that if two or more new Accounts are created in close sequence/simultaneously the following code will assign duplicated numbers rather than an incremented number for each:  public static void SetCustomId(Account account) {            CustomObj__c customObj = CustomObj__c.getOrgDefaults();      account.CustomAccountId__c = String.valueOf(Integer.valueOf(customObj.CustomCounter__c));     customObj.CustomCounter__c = customObj.CustomCounter__c + 1;      update customObj; }   Is there a way in Apex to lock a process so that a shared resource is used sequentially? In Java, C#, C++ etc. this is pretty easily done via a critical section if it's a single process or a Mutex if multiple processes access the same resource. Is there anything like this supported in Salesforce? Solutions beside Apex code/triggers would be fine as long as they meet the spec.   EDIT:  It is important that the object creates be sequential and not generate errors due to lockouts.
74931
Currently, when our Portal users send any emails from Salesforce, they are automatically BCC on each email. While they are able to delete their email address out of the BCC field, we would like to turn the automatic BCC off for all of our Portal users (but not org-wide; so we don't want to go with the option of enabling the Compliance BCC Email). We just want to change this setting for Portal users. Is there a way to do that?      trigger UserTrigger on User (before insert) { //This trigger is used to disable autobcc on email for portal users.     if(trigger.isBefore &amp;&amp; trigger.isInsert) {         List&lt;User&gt; lstUsers = new List&lt;User&gt;();         Set&lt;Id&gt; setUserLicenceId = new Set&lt;Id&gt;();         List&lt;Profile&gt; lstPortalUserLicense = [SELECT Id,Name FROM Profile WHERE Name = 'Partner Community User Custom'];         System.debug('Debug Log for lstPortalUserLicense'+lstPortalUserLicense.size());         if(lstPortalUserLicense.size() &gt;0){             for(Profile profile : lstPortalUserLicense) {                 setUserLicenceId.add(profile.ID);             }             for(User u : trigger.new){                 System.debug('Debug Log for userLicence '+u.ProfileID);                 System.debug('Debug Log for email bcc preference'+u.EmailPreferencesAutoBcc);                if(setUserLicenceId.contains(u.ProfileID)) {                    u.EmailPreferencesAutoBcc = false;                      lstUsers.add(u);                 }             }         }         System.debug('lstUsers size'+lstUsers.size());      } }
91232
I have created an app that would change CampaignMemeber Status Values by calling our web application api and storing info in custom objects. In my developer org where the package is created works fine but on our clients sandbox they get the error      System.QueryException: Non-selective query against large object type   (more than 200000 rows).   I know the reason that they get is because the query is not selective or that they have a lot of record. The error is occurring in a trigger. Below i have my trigger. Could anyone suggest a way to make my query more selective(i know about indexed field and tire that already) or any other way around the issue?    trigger SynchronizeTrigger on Attendee__c (after update, after insert) {      Map&lt;String,String&gt; matchedRegistration = new Map&lt;String,String&gt;();      Map&lt;String,String&gt; matchedCheckin = new Map&lt;String,String&gt;();      Set&lt;String&gt; matchedEmails = new Set&lt;String&gt;();      Map&lt;String,String&gt; matchedSurnames = new Map&lt;String,String&gt;();      CampaignMember[] cmList = new CampaignMember[]{};      List&lt;Fail__c&gt; flist = new List&lt;Fail__c&gt;();        Public Authentication__c auth = new Authentication__c();     auth = [SELECT Authentication_Campaign__c FROM Authentication__c LIMIT 1];        public Integer attendeesAttended = 0;     public Integer attendeesDidNotShow = 0;     public Integer attendeesAccepted= 0;     public Integer attendeesCancelled = 0;     public Integer attendeesfailed = 0;      for(Attendee__c a : Trigger.new){         matchedRegistration.put(a.Attendee_Email_Address__c,a.Attendee_Registration__c);         matchedCheckin.put(a.Attendee_Email_Address__c,a.Attendee_Checkin__c);          matchedEmails.add(a.Attendee_Email_Address__c);     }       for(List&lt;CampaignMember&gt; cms : [SELECT Id,Campaign.Id, Contact.Email,Status                            FROM CampaignMember                            WHERE  Campaign.Id =: auth.Authentication_Campaign__c AND  Contact.Email  IN: matchedEmails]){         for(CampaignMember cm : cms){            if(matchedRegistration.get(cm.Contact.Email)=='1' &amp;&amp; matchedCheckin.get(cm.Contact.Email)=='1'){                cm.Status = 'Attended';               cmList.add(cm);               attendeesAttended++;            }else if(matchedRegistration.get(cm.Contact.Email)=='1' &amp;&amp; matchedCheckin.get(cm.Contact.Email)=='0'){                cm.Status = 'Did Not Show';               cmList.add(cm);               attendeesDidNotShow ++;             }else if(matchedRegistration.get(cm.Contact.Email) =='1' &amp;&amp; String.isEmpty(matchedCheckin.get(cm.Contact.Email))){                cm.Status = 'Accepted';               cmList.add(cm);               attendeesAccepted ++;            }else if(matchedRegistration.get(cm.Contact.Email)=='0'){                cm.Status = 'Cancelled';               cmList.add(cm);               attendeesCancelled ++;                 }      update cmList;       }     }     for(List&lt;CampaignMember&gt; cms : [SELECT Id,Campaign.Id,FirstName,LastName,Contact.Email                            FROM CampaignMember                            WHERE Campaign.Id =: auth.Authentication_Campaign__c AND Contact.Email NOT IN: matchedEmails]){              for(CampaignMember cm : cms){              fList.add(new Fail__c(Fail_Firstname__c = cm.FirstName, Fail_Surname__c = cm.LastName, Fail_Email__c = cm.Contact.Email,Fail_Campaign_Name__c = cm.Campaign.Name ,Fail_Campaign__c = auth.Authentication_Campaign__c));             attendeesfailed ++;             upsert fList Fail_Email__c;           }   }     ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Confirm, 'Attended: ' + attendeesAttended + ' Delegate(s)' + ', ' + 'Did Not Show: ' + attendeesDidNotShow + ' Delegate(s)'+ ', ' + 'Accepted: ' + attendeesAccepted + ' Delegate(s)' + ', ' + 'Cancelled: ' + attendeesCancelled + ' Delegate(s)'));   ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Failed Syncs: ' + attendeesfailed + ' Delegate(s)')); }   Thanks