You need to sign in to do that
Don't have an account?
LoneStar69
Inbound Mail Handler Undeliverable email
Hi,
I am trying to check the incoming mail for a specific id, which will then send an email whether the id is found or not.
No errors in class.
Class -
global class ProcessIncomingEmail implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
String mySubject = email.subject;
String myReply = email.fromAddress;
Id s = '35987239';
Boolean b;
b = mySubject.contains(s);
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
if (b == true) {
try{
Messaging.SingleEmailMessage successmail = new Messaging.SingleEmailMessage();
successmail.setReplyTo('myReply');
successmail.setSenderDisplayName('Verification Update');
successmail.setSubject('Your Id is found:');
mails.add(successmail);
Messaging.sendEmail(mails);
}
catch (System.QueryException e){
System.debug('The issue is: ' + e);
}
}
else {
Messaging.SingleEmailMessage failmail = new Messaging.SingleEmailMessage();
failmail.setReplyTo('test@sample.com');
failmail.setSenderDisplayName('Verification Update');
failmail.setSubject('Your Id is not found:');
mails.add(failmail);
Messaging.sendEmail(mails);
}
result.success = true;
return result;
}
}
But gives the below error when i try to send email to the Email Service Address.
Error -
This message was created automatically by the mail system.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
>>> idverification@blah_blah_blah.cs33.apex.sandbox.salesforce.com (Undelivered):
554 The apex class ProcessIncomingEmail failed due to: System.StringException: Invalid id: 35987239
Thanks for your help!!!
I am trying to check the incoming mail for a specific id, which will then send an email whether the id is found or not.
No errors in class.
Class -
global class ProcessIncomingEmail implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
String mySubject = email.subject;
String myReply = email.fromAddress;
Id s = '35987239';
Boolean b;
b = mySubject.contains(s);
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
if (b == true) {
try{
Messaging.SingleEmailMessage successmail = new Messaging.SingleEmailMessage();
successmail.setReplyTo('myReply');
successmail.setSenderDisplayName('Verification Update');
successmail.setSubject('Your Id is found:');
mails.add(successmail);
Messaging.sendEmail(mails);
}
catch (System.QueryException e){
System.debug('The issue is: ' + e);
}
}
else {
Messaging.SingleEmailMessage failmail = new Messaging.SingleEmailMessage();
failmail.setReplyTo('test@sample.com');
failmail.setSenderDisplayName('Verification Update');
failmail.setSubject('Your Id is not found:');
mails.add(failmail);
Messaging.sendEmail(mails);
}
result.success = true;
return result;
}
}
But gives the below error when i try to send email to the Email Service Address.
Error -
This message was created automatically by the mail system.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
>>> idverification@blah_blah_blah.cs33.apex.sandbox.salesforce.com (Undelivered):
554 The apex class ProcessIncomingEmail failed due to: System.StringException: Invalid id: 35987239
Thanks for your help!!!
All Answers
Can you tell me one thing the id you have declared is for what
Id s = '35987239';
Error is coming from that only .
Please clarify .
It's just a random Id i want to check in the incoming email subject.
(Undelivered): 554 The apex class ProcessIncomingEmail failed due to: System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Missing target address (target, to, cc, bcc): []