You need to sign in to do that
Don't have an account?

Heeelp Email Service Test Class
Hi i must wrote test class to this class but i dont know how
Can somebody help ??
global class Emailservice implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
Contacts_History__c emaill = new Contacts_History__c ();
List<Candidate__c> CandiList = [SELECT ID FROM Candidate__c
WHERE E_mail__c =: email.fromAddress LIMIT 1];
emaill.Subject__c = email.subject;
emaill.Body__c = email.htmlBody;
emaill.Candidate__c = CandiList[0].id;
emaill.Date_of_contact__c = datetime.now();
emaill.Way_of_contact__c = 'E-mail';
String subToCompare = 'REC-';
Integer startNum = email.subject.IndexOf(subToCompare);
String phrase = email.subject.mid(startNum, 10);
/* List<Recruitment__c> recruitmentList = [SELECT ID FROM Recruitment__c
WHERE name = :phrase LIMIT 1];
if (!recruitmentList.isEmpty()) {
emaill.Recruitment__c = recruitmentList[0].id;
}*/
insert emaill;
if (email.textAttachments != null) {
for (Messaging.Inboundemail.TextAttachment tAttachment : email.textAttachments) {
Attachment attachment = new Attachment();
attachment.Name = tAttachment.fileName;
attachment.Body = Blob.valueOf(tAttachment.body);
attachment.ParentId = emaill.Id;
insert attachment;
}
}
//obsluga zalacznikow binarnych
if (email.binaryAttachments != null){
for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
Attachment attachment = new Attachment();
attachment.Name = bAttachment.fileName;
attachment.Body = bAttachment.body;
attachment.ParentId = emaill.Id;
insert attachment;
}
}
return result;
}
}
http://blog.jeffdouglas.com/2010/03/12/writing-an-inbound-email-service-for-salesforce-com/