+ Start a Discussion
Martin YMartin Y 

Invalid constructor name: EmailFileAttachment

Hi

 

I'm trying to use a function call to return a new email file attachment (I'm calling the subroutine from a few different places within the same batch class).  However, I'm getting a compilation error: invalid constructor name: EmailFileAttachment.  Does this mean I cannot return a Messaging.EmailFileAttachment constructor from a function, or am I doing something wrong?

 

private Messaging.EmailFileAttachment (Attachment AttachRec)
{
    // Create the mail message attachment
    Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
    attach.setContentType(AttachRec.ContentType);
    attach.setFileName(AttachRec.Filename);
    attach.setInline(false);
    attach.Body = AttachRec.body;
    return attach;
}

 

Many thanks in advance!

 

Martin

Best Answer chosen by Admin (Salesforce Developers) 
Jerun JoseJerun Jose
Doing a quick scan, I can see that there is no function name !!!

Shouldnt it be something like
private Messaging.EmailFileAttachment Func1(Attachment AttachRec)

All Answers

Martin YMartin Y

Shiv

 

Thanks for the speedy response, but I've seen this page and it doesn't help.  I know that I can add an attachment (and it works succesfully) but I would need to replicate my function call throughout my code a number of time.  So I really just want to pass the EmailFileAttachment variable returned from a function, but it appears that I cannot create a constructor to do this.

 

Does this make sense?

 

Martin 

Jerun JoseJerun Jose
Doing a quick scan, I can see that there is no function name !!!

Shouldnt it be something like
private Messaging.EmailFileAttachment Func1(Attachment AttachRec)
This was selected as the best answer
Martin YMartin Y

Oh dear.... I was completely focussing on the wrong thing wasn't I!  Many thanks Jerun!!!