我创建了一个Vf页面,其中显示与帐户相关的对象记录名称a,并带有复选框以供选择并联系为选择列表。
我想通过电子邮件将所选记录列表发送给所选联系人。如何在电子邮件方法中添加选定的联系人ID和选定的记录列表。我的代码在下面
public with sharing class Nex_Send_Email{
private ApexPages.StandardController standardController;
Private Id accID;
public List<SysWrapper> listSysWrapper {get; set;}
public List<NEX_System__c> selectedSystems{get;set;}
//private final List<Id> contactids ;
public ID contactID {get; set;}
public List<SelectOption> contactList{get;set;}
public string selectedContact { get; set; }
public string selectedReseller {get;set;}
public Nex_Send_Email(ApexPages.StandardController standardController)
{
accID= ApexPages.currentPage().getParameters().get('acId');
system.debug('accID::' +accID);
listSysWrapper = new List<SysWrapper>();
searchRecord();
List<Contact> oContact = [select id, Name, email from Contact where AccountId=:accID and Contact_Status__c = 'Active' and email !=null];
contactList = new List<SelectOption>();
contactList.add(new SelectOption('','--None--'));
for(Contact ct: oContact)
{
contactList.add(new SelectOption(ct.id,ct.Name+' - '+ct.email));
contactID = ct.Id;
system.debug('contactID ::' +contactID );
}
}
public void searchRecord()
{
listSysWrapper .clear();
for(NEX_System__c a: [select Id, Name from NEX_System__c where Nex_Account__c=:accID AND NEX_System_State__c='Active' limit 10])
{
listSysWrapper .add(new SysWrapper(a));
}
system.debug('listSysWrapper ::' +listSysWrapper);
}
public void processSelected()
{
selectedSystems= new List<NEX_System__c>();
selectedSystems.clear();
for(SysWrapper wrapAccountObj : listSysWrapper)
{
if(wrapAccountObj.selected == true)
{
selectedSystems.add(wrapAccountObj.acc);
system.debug('selectedSystems::' +selectedSystems);
}
}
}
// This is our wrapper/container class.
public class SysWrapper
{
public NEX_System__c acc {get; set;}
public Boolean selected {get; set;}
public SysWrapper(NEX_System__c a)
{
acc = a;
selected = false;
}
}
public void contactsrefresh()
{
system.debug('selected reseller:' +selectedReseller);
if (selectedReseller!=null)
{
contactList.clear();
List<Contact> resellercontacts = [select id, Name, email from Contact where (AccountId = :accID or AccountId = :selectedReseller) and Contact_Status__c = 'Active' and email !=null];
contactList.add(new SelectOption('','--None--'));
for (Contact rc :resellercontacts)
{
if(rc.accountid == accID)
{
contactList.add(new SelectOption(rc.id,rc.Name+' - '+rc.email));
}
}
for (Contact rc :resellercontacts)
{
if(rc.accountid != accID)
{
contactList.add(new SelectOption(rc.id,rc.Name+' - '+rc.email));
}
}
}
}
}