• Salman
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 43
    Replies
Dear Developers,

I have a custom email button on a custom object that works fine, however I have a couple of questions if anybody could help...?

1 - After clicking on button, user has to then search fro contact in the To field and then select email address - is it possible to add something to the button code (below) that will populate the To field automatically with the email address of the Primary Contact?

2 - Also we may have the need to send each email to a fixed internal email address (for checking) before forwarding on. is it possible to add something to the button code (below) that will allow the email to be sent to a fixed email address?

Many thanks, Rob 


{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} 

var query = "Select ContactId, OpportunityId, IsPrimary From OpportunityContactRole Where OpportunityId='{!Opportunity.Id}' AND IsPrimary=true"; 

var result = sforce.connection.query(query); 
var records = result.getArray("records"); 
var location ="/_ui/core/email/author/EmailAuthor?new_template=1&template_id=00X0Y000000IXbm&p3_lkid={!Match__c.Id}&retURL=/{!Match__c.Id}&rtype=003";; 
var contId =''; 
if (records != '') { 
contId = records[0].ContactId; 

if( contId != '' ){ 
location = location+"&p2_lkid="+contId; 

window.location=location ;
There are some Notes & Attachments on Lead.
When Send Email Button is clicked, under Attachment section, these things dont apppear.
Is there any way to display them automatically while sending Email?
 
I have used the mass email functionality  in my code but after sending emails 10 times jus to single person or 2 at a time i got the following error:
Visualforce Error
Help for this Page
System.EmailException: SendEmail failed. First exception on row 0; first error: MASS_MAIL_LIMIT_EXCEEDED, Email limit exceeded: []
Error is in expression '{!processSelected}' in component <apex:commandButton> in page sendmail: Class.ContactSelectClassController.processSelected: line 81, column 1
Class.ContactSelectClassController.processSelected: line 81, column 1
I am pasting  my code below:
Visualforcepage:
apex:pageBlock >
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Send Email" action="{!processSelected}" styleClass="sendemail" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Contacts" collapsible="false">
 
             <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.Email}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
               <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                   <apex:column value="{!c.Id}" headerValue="Contact"/>
                    <apex:column value="{!c.Name}" headerValue="Contact Name"/>
                    <apex:column value="{!c.Email}" headerValue="Email"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                    
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
            
        </apex:pageBlock> 
Controller:
public class ContactSelectClassController{
 
   
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Contact> selectedAccounts{get;set;}
    public String feedid;
    private  List<Id> contactids=new list<Id>();
    public List<Contact> conts;
   
    public List<Feedback_Contacts__c> feedcon{get;set;} 
    public ContactSelectClassController()
    {
     feedid= (ApexPages.currentPage().getParameters().get('fid'));
    system.debug('*********************Feedback id is :*********************************'+feedid);
     system.debug('*********************contactidscontactidscontactids:*********************************'+selectedAccounts);
           
        if(wrapAccountList == null)
         {
            wrapAccountList = new List<wrapAccount>();
            for(Contact a: [select Id, Name,Email,Phone from Contact])
             {
                wrapAccountList.add(new wrapAccount(a));
             }
         }
     }
   public pageReference CancelAction()
  {
    PageReference pr1 = new PageReference('/apex/LaunchPage');
   
    pr1.setRedirect(false);
    return pr1;
  } 

    public void processSelected()
     {
     
     feedid= (ApexPages.currentPage().getParameters().get('fid'));
     
       system.debug('*********************Feedback id feedidfeedid :*********************************'+feedid);
        system.debug('*********************contactidscontactidscontactids:*********************************'+selectedAccounts);
           
    selectedAccounts = new List<Contact>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList)
         {
            if(wrapAccountObj.selected == true)
             {
                selectedAccounts.add(wrapAccountObj.acc);
                 system.debug('*********************contactidscontactidscontactids:*********************************'+selectedAccounts);
           
             }
         }
         system.debug('*********************selectedAccountsselectedAccountsselectedAccounts*********************************'+selectedAccounts);
           
          for(Contact cont: selectedAccounts)
        {
           system.debug('*********************contactidscontactidscontactids:*********************************'+contactids);
            contactids.add(cont.Id);
            system.debug('*********************contactidscontactidscontactids:*********************************'+contactids);
        } 
        feedcon=new List<Feedback_Contacts__c>();
        for(Contact cont: selectedAccounts)
        {
        Feedback_Contacts__c fc=new Feedback_Contacts__c();
        fc.FeedbackContactName__c=cont.Id;
        fc.FeedBackNo__c='a0036000005RaG0';
        
        feedcon.add(fc);
        insert fc;
        // feedcon.add(cont.Id);
        // feedcon.add('a0036000005RaG0');
         
        } 
        
        Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
      system.debug('*********************selectedAccountsselectedAccountsselectedAccounts*********************************'+selectedAccounts);
   // system.debug('*********************s*********************************'+);
              
        mail.setTargetObjectIds(contactids);
        mail.setTemplateId('00X360000015j6P');
        Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
     }
 
    public class wrapAccount {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Contact a) {
            acc = a;
            selected = false;
        }
    }
}

How will i be able to get the limit for my org 
while sending emails to contacts i get single email limit exceed error. governer limit for sending single mail is 1000 per profile.
code is 
public class emailsender{


public void sendyourmail(){

  
  List<Messaging.SingleEmailMessage> mails = 
  new List<Messaging.SingleEmailMessage>();
 list<contact> li = [select id, name , email from contact limit 50];
  for (contact myContact :li) {
    if (myContact.Email != null && myContact.Name != null) {
        Messaging.SingleEmailMessage mail =   new Messaging.SingleEmailMessage();
           mail.setReplyTo('myemail@demo.com');
              mail.setSenderDisplayName('dummyemail');
             mail.setTargetObjectId(myContact.id); 
             mail.setTemplateId('00X28000000uJtC');    
            mails.add(mail);
    }
  }

  Messaging.sendEmail(mails);
      
    
    
    
    }

}
Hi,
I would like to know is there any possible work around to bypass the daily email limit that is going to be exceeded because of a trigger fire which sends an email alert, like with the help of @future method or through trigger etc

You can send mass email to a maximum of 1,000 external email addresses per day per organization
"external email addresses" in the above statement, is that mean the internal users of the organization or the email addresses belonging to another Org

Salesforce has different types of emails Like (general emails,single emails and workflow emails etc) so among them which type of email's limitation can be bypassed by work around.

lastly, Email limitation is subjected to ,
The no of emails allowed to send a particular user or No of receipients that are allowed to reveive the emails?
Hello all,

We have the following scalability issue.

We use emails internally to manage our operations and communications with clients, providers and internal employees. We have around 100 different types of emails that are sent programatically from APEX triggers, functions and webservices. Right now we send about 1000 emails daily and as we grow that number continues to increase (these are not mass emails, most emails are directed to only 1 recipient).

About a year ago we hit the 1,000 email mark for the first time and we basically had to shutdown our service because the operational emails couldn't be sent. At that point Salesforce increased our limit to 2,000. A couple of weeks ago we hit the 2,000 mark for the first time, but now it seems that the limit cannot be increased.

I have heard recommendations of using Pardot, ExactTarget and services like that. But, they offer a wide range of functionalities that we don't need and don't want to pay for.

Has anybody been able to solve this problem some other way? the important thing is to be able to send the emails from APEX code, having the flexibility of sending more emails.
  • November 06, 2014
  • Like
  • 0
workflow email template sending blank email to the recipient .
Please can anyone  suggest me the way to get out of this problem

Hi,

 

When I try to send a common email to all my contacts in Developer edition, I can only send up to 10 contacts in a day. How is it possible to send a common mail to 100 contacts in same day?

  • December 13, 2013
  • Like
  • 0

Hello SalesForce experts,

 

We have a limit of 1500 mass emails per day. (We were intially limited to 1000, we asked to increase this)

 

Now 1500 is not enough for us, we need to increase this size.

 

Is this a money issue? Is it possible to increase the limit over 1500?

 

Thanks,

David

Hi EveryOne

 

              i am send Emails to My campaignmember contacts..thoe contatcs are totally 32..for tht i wrote batch apex and  scheduled this. it saves but   emails are sent to 1st 10 members only..after i am trying to send emails again it  throws an error in apex jobs(mass email limit exceeds)

 

using batch apex is it possible sent 32 emails at a time??

 

my approch

global class campaignmem implements  Database.Batchable<sobject>,Schedulable {

global final string query= 'select id,campaignid,contactid from campaignmember';   

Private final list<id> Eids=new list<id>();
global campaignmem()
{
   List<Contact> cons  = new List<Contact>();
 
  for(campaignmember cam :[select id,campaignid,contactid from campaignmember])
  {
        if(cam.contactid !=null)
    {
     cons=[select id,name,email from contact where id =:cam.contactid];
     for(Contact c:cons)
     {
       if(c.id!=null)
       {
       Eids.add(c.id);        
       }
     }
     
    }
  }   
   System.debug('--- CampaignMembers ' + query);

}
global void execute(SchedulableContext SC) {
    // invoke business logic - this method is strictly to invoke
    // the method from the scheduler...
   campaignmem CM2 = new campaignmem();
   ID batchprocessid = Database.executeBatch(CM2,10);
   
 }  
global Database.QueryLocator start(Database.BatchableContext BC)
{

   return Database.getQueryLocator(this.query);
}

global void execute(Database.BatchableContext BC, List<campaignmember> scope)
{
    Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
       mail.setTargetObjectIds(Eids);
       mail.setTemplateId('00XE0000000s29O');
       Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
}
global void finish(Database.BatchableContext BC){

     

}
}

  • October 12, 2012
  • Like
  • 0

From a Lead or Contact, you can click the "Send an Email" button (/_ui/core/email/author/EmailAuthor...) and choose a visualforce email template. However, how does one populate the template's recipient record and relatedTo record? Are there parameters that can be passed to populate these? The org is PE and does not have Apex, so the solution must not require Apex code. 

 

Thanks

 

Jeremy

 

 

Hi!

 

I need to upload a 22MB file to Document. Uploading this PDF to File or Content is the last option but before that, i'd like to ask if anyone has an idea on how to bypass the 5MB limit for documents?

 

Than kyou!

Hi

 

I need to get only List View of an Object on VF page.Is it possible to get only those 

picklist values that are in list view of a particular object.

 

 

Thanks

Hello,

 

We are sending emails on tasks based on the task status values. As we cannot create Email Alerts for Tasks, we had to send mails through Apex code.

 

Here is where there is a limit of 500 emails per day for an EE Edition as per the documentation. But, it is also mentioned that this does not include the emails sent out to the users inside the org as they are internal.

 

Only emails sent to outside addresses are added to the count. But, in our case, we are hitting this limit even though we send out mails to internal users.

 

Anyone, has any idea, as to what is the basis/criteria, salesforce checks/calculates this count of emails sent from API?

 

Many Thanks,

Cool_D

Hi i want to know the current emails sent out and the email limit for the an org using apex, can this be done?

It is said that mass email is allowed to send 250 mails per call and  up to 1000 mails per day.

But I found the article on the page 181 of  the book "Development with the Force.com Platform" by Jason Quellette

saying  "You can reach 2,500 recipients using the MassEmailMessage ". On this book  said  " 250 recipients times the 10 invocation maximum".

Is it true we can send 2500 mails per pay ?

Any suggestion appreciated.

 

     Yoshio Takemura

  • April 02, 2010
  • Like
  • 0

Hi,

My understanding is that an org can only send 1000 emails per day.

 

If we have a @future method that execute the sendEmail() method:

 

 

@future public void sendEmailInFuture(){ Messaging.sendEmail(); }

 

And we call this method from other classes. When it reaches the limit, would the remaining messages be sent the next day when the limit is reset?

 

Thanks.

 

 

<script src="/soap/ajax/12.0/connection.js"></script>

some other code.

var attachments = new Array("000000000000000"); //replaced 000000000000000 with the document id in SF.
singleRequest.documentAttachments = attachments;

var sendMailRes = sforce.connection.sendEmail([singleRequest]);

I am not able to get this to work at all....

Example was shown with a 9.0 connection...I tried with that as well, but the email didn't go out.

thx in advance.
  • September 18, 2008
  • Like
  • 0
Is it possible to redirect to the email page, pass a SalesForce document id and have the document already attached?

Basically, we want to have an external program add documents to a users document library and then redirect to the email page with that new document already listed as an attachment.