2010-07-05 10 views
2

나는 OL 추가 기능을 가지고 (C# COM 추가 기능 표현 사용) 그러나 기본 서명의 원인이프로그래밍

mailItem = (Outlook.MailItem)OutlookApp.CreateItem(Outlook.OlItemType.olMailItem); 
mailItem.To = ReceipientEmailAddress; 
mailItem.Subject = "SOME TEXT"; 
mailItem.Body = NewBody; 
mailItem.Display(false); 

이 같은 일을하고있다가 내가

오이 OL 2007 인 서명을 포함하는 메일 작성을 어떤 방법으로 서명을 읽거나 야기 할 수없는 나는 내가 newBody가 설정되고 있기 때문에 이것이 가정하고 를 사라지게하는 .NET 2.0

답변

7

나는 똑같은 문제가 있었고 아무런 대답도 찾지 못했습니다. 그래서 직접 서명을 얻으려고이 문제를 해결하기로 마음 먹었습니다.

 private string ReadSignature() 
    { 
     string appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Microsoft\\Signatures"; 
     string signature = string.Empty; 
     DirectoryInfo diInfo = new DirectoryInfo(appDataDir); 
     if (diInfo.Exists) 
     { 
      FileInfo[] fiSignature = diInfo.GetFiles("*.htm"); 
      if (fiSignature.Length > 0) 
      { 
       StreamReader sr = new StreamReader(fiSignature[0].FullName, Encoding.Default); 
       signature = sr.ReadToEnd(); 

       if (!string.IsNullOrEmpty(signature)) 
       { 
        string fileName = fiSignature[0].Name.Replace(fiSignature[0].Extension, string.Empty); 
        signature = signature.Replace(fileName + "_files/", appDataDir + "/" + fileName + "_files/"); 
       } 
      } 
     } 

     return signature; 
    } 

희망이 도움이됩니다.

+0

흥미로운 것은 2007 년과 2010 년에 효과가 있습니까? – Rahul

+0

Outlook 2007에서 사용하고 있습니다. 2010 년에도 작동합니까? – Albert

+0

예,이 코드는 MS Outlook 2010에서도 작동합니다. – Frank

1

이 코드는 추가 코드 없이도 사용할 수 있습니다. 이 도움이


      olMail = outlook.CreateItem(0); 
          olMail.To = toEmailID; 
          olMail.Subject = "Subject"; 

          if (attachments != null) 
          { 
           foreach (var path in attachments) 
           { 
            olMail.Attachments.Add(path); 
           } 
          } 

          olMail.Display(); 
          //Display email first and then write body text to get original email template and signature text. 

          if (string.IsNullOrWhiteSpace(htmlBody)) 
          { 
           if (!string.IsNullOrWhiteSpace(body)) 
           { 
            olMail.Body = body + olMail.Body; 
           } 
          } 
          else 
          { 
           olMail.HTMLBody = htmlBody + olMail.HTMLBody; 
          } 

희망.