+ Start a Discussion
Bill FoxBill Fox 

Invalid initial expression type for field, expecting: String

I am trying to read the "toAddresses" field in apex in global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,                                                            Messaging.InboundEnvelope env)
I getting an error: Invalid initial expression type for field Email_PO__c.email_toAddresses__c, expecting: String
I suspect I need some code to convert this field of data to a string separated by commas?

String Error
You are trying to assign a array of string to string field so you are getting this error message. Email.toaddresses always return string[] value
Inculde the belwo code and assign Email_PO__c.email_toAddresses__c =  listToAddress
String listToAddress = '';
for(String str: email.toAddresses)   {
    listToAddress += str+',';