+ Start a Discussion
Joey HoJoey Ho 

@isTest for standard Inbound Email-To-Case

Hi All, 


This is driving me nuts. I can understand how to write a test class for 'customer' inbound message handlers but how do I start off righting a test method and creating a inbound test message for testing the standard Email-To-Case service that salesforce provides???


I'm sure it is bluntly obviously but can not figure it out!


Actually.... thinking about it, is creating a Case the same as testing inbound email-to-case so therefore I wouldn't need to create any such test method other than a new case?






Never tried to do it myself but maybe something like this could work:


global class EmailToCase implements Messaging.InboundEmailHandler {
	global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
		// logic 	 

private class EmailToCaseTest {
	static testMethod void test() {
		//set up     	    	
		Messaging.InboundEmail email = new Messaging.InboundEmail();
		email.Subject = '______';
		email.plainTextBody = null;
		Messaging.InboundEnvelope envelope = new Messaging.InboundEnvelope();
		EmailToCase mailer = new EmailToCase(); 
		//run test
			mailer.handleInboundEmail(email, envelope);