• achyuth dasam
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hello,
I have been going through this code for an hour now and cannot figure out why it is an "Illegal Assignment from String to List". Isn't an Email field a string?

The error is shown at the line I flagged, however the error might be somewhere else in my code too.
public class sendEmail {
    public String subject { get; set; }
    public String body { get; set; }
 
    private final <Object> WebInquiry;
 
    // Create a constructor that populates the Account object
    public sendEmail() {
        WebInquiry = [SELECT Email__c FROM <Object> WHERE id = :ApexPages.currentPage().getParameters().get('id')];
    }
 
    public <Object> getWebInq() {
        return WebInquiry;
    }
 

    public PageReference send(){
        // Define the email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
 
String address;
        address = WebInquiry.Email__c;

****ERROR HERE****        String[] toAddresses = address;
 
        // Sets the paramaters of the email
        email.setSubject( subject );
        email.setToAddresses( toAddresses );
        email.setPlainTextBody( body );
   
        // Sends the email
        Messaging.SendEmailResult [] r =
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});  
        
        return null;
    }

}

Thanks for your help!
Ryan