2013-03-26 34 views
1

我正在使用php-ews發送郵件,而且我無法找到設置郵件重要性(優先級)的方法。 這裏是我的代碼:php-ews如何在發送電子郵件時設置重要性



    $from = $mail['from']; 
    $to = $mail['to']; 
    $subject = $mail['subject']; 
    $body = $mail['body']; 

    $msg = new EWSType_MessageType(); 
    if($to && count($to) > 0){ 
     $toAddresses = $this->getAddresses($to); 
     $msg->ToRecipients = $toAddresses; 
    } 

    $fromAddress = new EWSType_EmailAddressType(); 
    $fromAddress->EmailAddress = $from['mail']; 
    $fromAddress->Name = $from['name']; 

    $msg->From = new EWSType_SingleRecipientType(); 
    $msg->From->Mailbox = $fromAddress; 

    $msg->Subject = $subject; 

    $msg->Body = new EWSType_BodyType(); 
    $msg->Body->BodyType = 'HTML'; 
    $msg->Body->_ = $body; 

    $msgRequest = new EWSType_CreateItemType(); 
    $msgRequest->Items = new EWSType_NonEmptyArrayOfAllItemsType(); 

    $msgRequest->Items->Message = $msg; 
    $msgRequest->MessageDisposition = 'SendAndSaveCopy'; 
    $msgRequest->MessageDispositionSpecified = true; 

    $response = $this->ews->CreateItem($msgRequest); 
    return $response; 

預先感謝您的迴應!

回答

0

您需要加載EWSType_ImportanceChoicesType類。您的代碼應該是這樣的:

$from = $mail['from']; 
$to = $mail['to']; 
$subject = $mail['subject']; 
$body = $mail['body']; 

$msg = new EWSType_MessageType(); 
if($to && count($to) > 0){ 
    $toAddresses = $this->getAddresses($to); 
    $msg->ToRecipients = $toAddresses; 
} 

$fromAddress = new EWSType_EmailAddressType(); 
$fromAddress->EmailAddress = $from['mail']; 
$fromAddress->Name = $from['name']; 

$msg->From = new EWSType_SingleRecipientType(); 
$msg->From->Mailbox = $fromAddress; 

$msg->Subject = $subject; 

$msg->Body = new EWSType_BodyType(); 
$msg->Body->BodyType = 'HTML'; 
$msg->Body->_ = $body; 

$msgRequest = new EWSType_CreateItemType(); 
$msgRequest->Items = new EWSType_NonEmptyArrayOfAllItemsType(); 

$msgRequest->Items->Message = $msg; 
// Start importance code 
$msgRequest->Items->Message->Importance = new EWSType_ImportanceChoicesType(); 
$msgRequest->Items->Message->Importance->_ = EWSType_ImportanceChoicesType::HIGH; 
// End importance code 
$msgRequest->MessageDisposition = 'SendAndSaveCopy'; 
$msgRequest->MessageDispositionSpecified = true; 

$response = $this->ews->CreateItem($msgRequest); 
return $response; 

要改變的重要性剛剛更改以下行的結尾有高,低或正常:

$msgRequest->Items->Message->Importance->_ = EWSType_ImportanceChoicesType::HIGH; 
0

我不是很熟悉php,但如果我使用C#的mailmessage類有一個「重要性」屬性這是一個枚舉,可以設置爲:高,低和正常。默認爲「正常」。

希望這有助於你...

+0

你可能使用EWS託管API爲C#,它是EWS Web服務的包裝器。在我的情況下,我無法使用它。 謝謝你的迴應。 – 2013-03-27 13:28:38

相關問題