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일 오전 12: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