Skip to main content
Bill Fox 提问于 #Apex
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?

Invalid initial expression type for field, expecting: String
1 个回答
  1. 2015年1月25日 00:50
    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+',';

    }

     
0/9000