function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AmitZAAmitZA 

Use startWithIgnoreCase to recognize an email

I am looking to write a class on the Task object to categorize emails coming in or going out of the system when they are forwarded into the system by Email-To-Salesforce BCC address but they are synced the same except:

Additional To: xxxx@xxxx.com
CC:
BCC:
Attachment:

should be categorized as an Outgoing Email

while 

Additional To: 
CC:
BCC:
Attachment:

should be categorize as an Incoming Email.

How should the I write the IF statement?

Thanks!
Best Answer chosen by AmitZA
Marzorati ClaudioMarzorati Claudio
Hi Amit,

for Incoming Email you don't report any rule. I think that you must identify a rule to understand the difference between the two cases.
When you have the rule it will be easy to do an if-else statement to write your test class.

Without anymore info it is difficult to help you

Claudio

All Answers

Marzorati ClaudioMarzorati Claudio
Hi Amit,

for Incoming Email you don't report any rule. I think that you must identify a rule to understand the difference between the two cases.
When you have the rule it will be easy to do an if-else statement to write your test class.

Without anymore info it is difficult to help you

Claudio
This was selected as the best answer
AmitZAAmitZA
Hi Claudio,
Thanks for your time on answering my question.

I am looking to take the Task's Description field (textarea 32000)

Additional To: 
CC:
BCC:
Attachment:


Cut only the first line:
Additional To: 
and then my IF statement will be if that first line is over 16 chars, then it is of type Outgoing Email, if it is 16 or less then it is incoming.

I have created something which works:
List<String> firstLineOfDesc=task.Description.split('\n');
                    System.debug('The string is: '+firstLineOfDesc);
                    System.debug('The string length is: '+firstLineOfDesc[0].length());
                    
                         if (firstLineOfDesc[0].length()>16){
                            task.Type='Outgoing Email';
                            }
                            else {
                            task.Type='Incoming Email';    
                            }

It is a fragile logic but until this will have to make do for now.
If you have any recomendations for editing, I would appreciate your insights.

Grazie Mille,
Amit
Marzorati ClaudioMarzorati Claudio
Hi Amit,

yes this is a fragile logic, but actually I don't see another way to test this think.

Don't you have any others attributes on your email (maybe a value in object that you can looking for)?

Prego
Claudio
AmitZAAmitZA
Unfortunatly not. The Email-To-Salesforce functionality is quite poor and except the emails appearing in the Description field there is no difference.
Thanks again for your feedback.

Cordiali Saluti,
Amit