You need to sign in to do that
Don't have an account?
![sangam Bp 39 sangam Bp 39](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
I am Stuck In Test Class,for this class pls help me
public class Send_Offer_Letter
{
public Send_Offer_Letter() {
}
public string conemailcall{get;set;}
// public string emailBodyNew {get;set;}
public User MyUser {get;set;}
public String ToSab {get;set;}
// public String ToMau {get;set;}
// public List<Contact> Contact_Email_ID {get;Set;}
public string cc2 {get;set;}
//public string EmailBody {set;get;}
//public string Subject {get;set;}
// Public string[] Con_Email_ids {get;set;}
public Contact myoffer{get;set;}
list<string> l1=new list<string>{'sangam8029@gmail.com'};
public string contname{get;set;}
// public string test_email{get;set;}
// public contact m2{get;set;}
public string conname{get;set;}
Public Contact cc_lst{get;set;}
Public String toAdd;
Public String[] ccAdd{get;set;}
public ID parentId {get;set;}
// public String pdfName {get;set;}
public contact cc_clst{get;set;}
//public contact offer{get;set;}
public Send_Offer_Letter(ApexPages.StandardController controller)
{
string id_c = ApexPages.currentPage().getParameters().get('id');
parentid=id_c;
myoffer = [Select id,name from contact Where id =: id_c];
MyUser = [Select Name,Email From User Where User.id =: UserInfo.getUserId()];
cc_clst = [select id,name,Email,Joining_Date__C,Designation__C from Contact where id=: id_c and Recordtypeid='012p00000004ekH'];
//conname = cc_clst.Email ;
conemailcall=cc_clst.email;
ccAdd = new String[]{};
contname=cc_clst.name;
cc2 = cc2+cc_clst.email+',';
cc2 = cc2.removeEnd(',');
ccAdd = cc2.split(',');
}
public PageReference sendEmail()
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
system.debug('@@@@@@@@@'+cc_clst.Email);
mail.setTargetObjectId(cc_clst.id);
mail.setPlainTextBody('plainTextBodrrrrrry');
system.debug('@@@@@@@@@@@@@plainTextBodrrrrrry');
mail.setHtmlBody('<html><body><p><b>Dear</b><b> </b><b>'+contname+'</b><b>,</b></p><p><font color="Blue">We take pleasure in appointing you with our company as '+cc_clst.Designation__C+' .</p><p><b>Date of Appointment</b><b>:</b></p><p>Your appointment is effective from the date of joining which shall be as soon as possible but not later than '+cc_clst.Joining_Date__C+'.</p><p><b><u>Mandatory List of documents to be produced on joining:</u></b></p><p>1. Testimonials (<b>class 10 / 12 / All semester wise mark sheets and Degree Certificates)</b><b> </b>and the Photocopy<b>.</b></p><p>2. Passport size recent photographs</p><p>3. Passport Copy, Age & permanent address Proof.</p><p>Please confirm your acceptance of this final Offer Letter in return mail to precede further process. Do feel free to write for any query or clarificationyou may have.</p><p><b><>/b></p><p>He</p><p></p><p>Tel: +</p><p>Mobile: +91 8041229365</p><p>Email: <u></u></p><p><u><a href="http://"></a></u></p></body></html>');
// mail.setCcAddresses(conname);
PageReference pdf = Page.OfferLetterFormat;
pdf.getParameters().put('id',(String)cc_clst.id);
pdf.setRedirect(true);
Blob b = pdf.getContent();
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName('Offer Letter.pdf');
efa.setBody(b);
mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
return new PageReference('/'+cc_clst.id);
}
}
{
public Send_Offer_Letter() {
}
public string conemailcall{get;set;}
// public string emailBodyNew {get;set;}
public User MyUser {get;set;}
public String ToSab {get;set;}
// public String ToMau {get;set;}
// public List<Contact> Contact_Email_ID {get;Set;}
public string cc2 {get;set;}
//public string EmailBody {set;get;}
//public string Subject {get;set;}
// Public string[] Con_Email_ids {get;set;}
public Contact myoffer{get;set;}
list<string> l1=new list<string>{'sangam8029@gmail.com'};
public string contname{get;set;}
// public string test_email{get;set;}
// public contact m2{get;set;}
public string conname{get;set;}
Public Contact cc_lst{get;set;}
Public String toAdd;
Public String[] ccAdd{get;set;}
public ID parentId {get;set;}
// public String pdfName {get;set;}
public contact cc_clst{get;set;}
//public contact offer{get;set;}
public Send_Offer_Letter(ApexPages.StandardController controller)
{
string id_c = ApexPages.currentPage().getParameters().get('id');
parentid=id_c;
myoffer = [Select id,name from contact Where id =: id_c];
MyUser = [Select Name,Email From User Where User.id =: UserInfo.getUserId()];
cc_clst = [select id,name,Email,Joining_Date__C,Designation__C from Contact where id=: id_c and Recordtypeid='012p00000004ekH'];
//conname = cc_clst.Email ;
conemailcall=cc_clst.email;
ccAdd = new String[]{};
contname=cc_clst.name;
cc2 = cc2+cc_clst.email+',';
cc2 = cc2.removeEnd(',');
ccAdd = cc2.split(',');
}
public PageReference sendEmail()
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
system.debug('@@@@@@@@@'+cc_clst.Email);
mail.setTargetObjectId(cc_clst.id);
mail.setPlainTextBody('plainTextBodrrrrrry');
system.debug('@@@@@@@@@@@@@plainTextBodrrrrrry');
mail.setHtmlBody('<html><body><p><b>Dear</b><b> </b><b>'+contname+'</b><b>,</b></p><p><font color="Blue">We take pleasure in appointing you with our company as '+cc_clst.Designation__C+' .</p><p><b>Date of Appointment</b><b>:</b></p><p>Your appointment is effective from the date of joining which shall be as soon as possible but not later than '+cc_clst.Joining_Date__C+'.</p><p><b><u>Mandatory List of documents to be produced on joining:</u></b></p><p>1. Testimonials (<b>class 10 / 12 / All semester wise mark sheets and Degree Certificates)</b><b> </b>and the Photocopy<b>.</b></p><p>2. Passport size recent photographs</p><p>3. Passport Copy, Age & permanent address Proof.</p><p>Please confirm your acceptance of this final Offer Letter in return mail to precede further process. Do feel free to write for any query or clarificationyou may have.</p><p><b><>/b></p><p>He</p><p></p><p>Tel: +</p><p>Mobile: +91 8041229365</p><p>Email: <u></u></p><p><u><a href="http://"></a></u></p></body></html>');
// mail.setCcAddresses(conname);
PageReference pdf = Page.OfferLetterFormat;
pdf.getParameters().put('id',(String)cc_clst.id);
pdf.setRedirect(true);
Blob b = pdf.getContent();
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName('Offer Letter.pdf');
efa.setBody(b);
mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
return new PageReference('/'+cc_clst.id);
}
}
use below Test class for your class.
Hope this will help you
Mark it Best ANSWER if its work for you.
Thanks
karthik