1

我正在使用 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;

预先感谢您的回复!

4

2 回答 2

1

您需要加载 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;

要更改重要性,只需将以下行的结尾更改为 HIGH、LOW 或 NORMAL:

$msgRequest->Items->Message->Importance->_ = EWSType_ImportanceChoicesType::HIGH;
于 2013-04-25T19:49:16.687 回答
0

我不太熟悉 php,但如果我使用 C#,邮件消息类有一个“重要性”属性,它是一个枚举,可以设置为:高、低和正常。默认为“正常”。

希望这可以帮助你...

于 2013-03-27T12:42:13.613 回答