2014-12-10 3 views
1

Powershell v3의 Exchange Web Services Managed API를 사용하여 메시지를 보낼 때 회신 헤더를 어떻게 설정합니까?어떻게 메시지를 설정 하시겠습니까? EWS Managed API를 사용하여 회신 주소를 지정 하시겠습니까?

Microsoft.Exchange.WebServices.Data.EmailMessage 개체가 있고 보낸 사람 주소를 설정하고 첨부 파일을 추가하고 메일을 성공적으로 보낼 수 있습니다.

나는 사용하여 X- 헤더 추가 할 수 있었다 :

$xheader = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::InternetHeaders,"x-my-header",[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String) 

을와 $ pspropset에 추가하지만 값으로 회신을 사용하는 경우 헤더가 삽입되지 않습니다.

Gloss Scales 님이 게시 한 정보를 찾기가 어렵습니다. this thread 두 확장 속성 (PidTagReplyRecipientEntriesPidTagReplyRecipientNames)을 EmailMessage 개체에 설정해야한다고 생각합니다.

확장 속성을 모두 오류없이 설정할 수 있지만 메시지에 회신 헤더가 표시되지 않습니다. 아래

관련 코드 :

function SendResponse($orgMsg, $bodyTxt){ 
$message = [Microsoft.Exchange.WebServices.Data.EmailMessage]::Bind($service, $($orgMsg.Id), $psPropset) 
$reply = $message.CreateReply($true) 
$reply.BodyPrefix = $bodyTxt 
$replyMsg = $reply.Save($drftFolderid.Id) 
$replyMsg.From = "[email protected]" 
$replyMsg.SetExtendedProperty($PidTagReplyRecipientEntries, $byteVal) 
$replyMsg.SetExtendedProperty($PidTagReplyRecipientNames, "[email protected]") 
$replyMsg.Update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AlwaysOverwrite) 
$replyMsg.SendAndSaveCopy($sentFolderid.Id) 
} 

function convert-fromhex { 
    process 
    { 
     $_ -replace '^0x', '' -split "(?<=\G\w{2})(?=\w{2})" | %{ [Convert]::ToByte($_, 16) } 
    } 
} 

# below is hex of string "[email protected]" 
[Byte[]]$byteVal = "6d795f646573697265645f7265706c79746f406578616d706c652e636f6d" | convert-fromhex 

$PidTagReplyRecipientEntries = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x004F,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Binary) 
$PidTagReplyRecipientNames = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x0050,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String) 
$psPropset = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) 
$psPropset.Add($PidTagReplyRecipientEntries) 
$psPropset.Add($PidTagReplyRecipientNames) 

사람이 성취 할 수있는 방법을 알고 있나요?

+0

이 질문에 투표 한 이유에 대한 통찰력도 인정됩니다. – runaboutfence

+0

회신 메일을 Exchange 메일 그룹으로 지정하려는 경우 동일한 문제가 발생하므로 가장을 사용할 수 없습니까? – Aaron

답변

0

당신이 downvoted 이유는 모르지만, 클래스에 an EmailMessage.ReplyTo property 인 것처럼 보입니다. 그러나 읽기 전용인지는 알 수 없습니다. 있을 수도있는 것처럼 보입니다.

+0

답장을 보내 주셔서 감사합니다! EmailMessage 클래스의'EmailMessage.ReplyTo' 속성은 읽기 전용입니다. 확장 속성'PidTagReplyRecipientEntries'와'PidTagReplyRecipientNames'가 올바르게 설정되어있을 때이 속성이 Exchange 전송 공급자에 의해 설정되었다고 생각합니다. – runaboutfence

0

내가 아는 한 당신은 할 수 없습니다. Replyto은 읽기 전용 속성입니다. 나는 'ImpersonatedUserId'를 사용하려고 노력해 왔지만 조금 어수선 해 보인다. 그러나 당신이 가장 권한을 가지고 있다면 From 속성을 설정할 수 있다는 것을 알았습니다. 그러면 보내질 것입니다. 나는 이것이 당신이 찾고있는 것이 아닐 수도 있다는 것을 이해하지만 이메일이 올바른 곳에서 오기를 기대할 것입니다.