problem sending email with attachment

Discussion in 'Programming/Scripts' started by marleyblu, Jun 7, 2011.

  1. marleyblu

    marleyblu New Member

    I'm new to using EWS from Exchangeclient classes.

    I'm looking for a simple example how to send an email with an attachment. I've found examples about how to send an email but not sending an email with an attachment.

    This is my script:
    PHP:
    $exchangeclient = new Exchangeclient();
    $exchangeclient->init($username$passwordNULL'ews/Services.wsdl');
    $exchangeclient->send_message($mail_from$subject$body'HTML'truetrue);

    I have the following soap request.
    PHP:
    $CreateItem->MessageDisposition "SendAndSaveCopy";
        
    $CreateItem->SavedItemFolderId->DistinguishedFolderId->Id "sentitems";

        
    $CreateItem->Items->Message->ItemClass "IPM.Note";
        
    $CreateItem->Items->Message->Subject $subject;
        
    $CreateItem->Items->Message->Body->BodyType $bodytype;
        
    $CreateItem->Items->Message->Body->$content;
        
    $CreateItem->Items->Message->ToRecipients->Mailbox->EmailAddress $to
    $CreateItem->Items->Message->Attachments->FileAttachment->AttachmentId $attach['AttachmentId'];
        
    $CreateItem->Items->Message->Attachments->FileAttachment->Name $attach['Name'];
        
    $CreateItem->Items->Message->Attachments->FileAttachment->ContentType $attach['ContentType'];
        
    $CreateItem->Items->Message->Attachments->FileAttachment->ContentId $attach['AttachmentId'];
        
    $CreateItem->Items->Message->Attachments->FileAttachment->Content $attach['ContentId'];
        
    $CreateItem->Items->Message->Attachments->FileAttachment->Size $attach['Size'];
    The error I am getting is:

    Fatal error: Uncaught SoapFault exception: [a:ErrorSchemaValidation] The request failed schema validation: The required attribute 'Id' is missing.

    Thanks.
     

Share This Page