1

Outlook에서 새 메일을 작성할 때 제목을 새로 설정할 수 있지만 텍스트를 앞에 추가하려고합니다. 그래서 먼저 주제를 얻고 설정해야합니다.Outlook에서 편지 쓰기 항목의 제목에 액세스하는 방법

Outlook.Application application = Globals.ThisAddIn.Application; 
Outlook.Inspector inspector = application.ActiveInspector(); 
Outlook.MailItem myMailItem = (Outlook.MailItem)inspector.CurrentItem; 

if (myMailItem != null && !string.IsNullOrEmpty(myMailItem.Subject)) 
{ 
    myMailItem.Subject = "Following up on your order"; 
} 

이 코드는 응답에서 작동하지만 새 메시지에는 적용되지 않습니다.이 경우 myMailItem은 null입니다.

답변

1

이것은 내가 찾고 있었던 것입니다 :

if (thisMailItem != null) 
{ 
    thisMailItem.Save(); 

    if (thisMailItem.EntryID != null) 
    { 
     thisMailItem.Subject = "prepended text: " + thisMailItem.Subject; 
     thisMailItem.Send(); 
    } 
} 

피사체가 null의 메일 항목이 저장 될 때까지,이 전송하거나 초안으로 된 하나 때문이다. 프로그래밍 방식으로 저장 한 다음 주제를 가져올 수 있습니다.

다른 한 가지 메모 : 저장시 대상이 비어 ​​있으면 계속 null로 표시됩니다.

0

CurrentItem은 현재 전자 메일 항목입니다.

새로운 것을 만들어야합니다.

Outlook.MailItem mic = (Outlook.MailItem)(application.CreateItem(Outlook.OlItemType.olMailItem));