728x90
728x170
▶ CustomAddIn.cs
using Microsoft.Office.Interop.Outlook;
using System;
using System.IO;
using System.Reflection;
namespace TestProject
{
/// <summary>
/// 커스텀 애드인
/// </summary>
public partial class CustomAddIn
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
//////////////////////////////////////////////////////////////////////////////// Event
#region 커스텀 애드인 시작시 처리하기 - CustomAddIn_Startup(sender, e)
/// <summary>
/// 커스텀 애드인 시작시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void CustomAddIn_Startup(object sender, EventArgs e)
{
#region 설치 디렉토리 경로를 설정한다.
Assembly assembly = Assembly.GetExecutingAssembly();
Uri codeBaseURI = new Uri(assembly.CodeBase);
string installDirectoryPath = Path.GetDirectoryName(codeBaseURI.LocalPath);
#endregion
MailItem mailItem = (MailItem)Application.CreateItem(OlItemType.olMailItem);
mailItem.Subject = "테스트 메일 입니다.";
mailItem.To = "icodebroker@naver.com";
mailItem.BodyFormat = OlBodyFormat.olFormatHTML;
mailItem.HTMLBody = @"
<html>
<head></head>
<body>
Hello,<br><br>
This is a working example of embedding an image unsing C# :<br><br>
<img align=""baseline"" border=""1"" hspace=""0"" src=""cid:image0001"" width=""600"" /></img><br><br>
Regards,<br>icodebroker
</body>
</html>";
string imageFilePath = Path.Combine(installDirectoryPath, "IMAGE", "sample.png");
Attachment attachment = mailItem.Attachments.Add(imageFilePath);
attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x370E001F", "image/png");
attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "image0001");
// 모든 첨부 파일들을 숨긴다.
mailItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8514000B", true);
mailItem.Display(false);
}
#endregion
#region 커스텀 애드인 셧다운시 처리하기 - CustomAddIn_Shutdown(sender, e)
/// <summary>
/// 커스텀 애드인 셧다운시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void CustomAddIn_Shutdown(object sender, EventArgs e)
{
}
#endregion
//////////////////////////////////////////////////////////////////////////////// Function
#region VSTO에서 생성한 코드
/// <summary>
/// 디자이너 지원에 필요한 메서드입니다.
/// 이 메서드의 내용을 코드 편집기로 수정하지 마세요.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(CustomAddIn_Startup );
this.Shutdown += new System.EventHandler(CustomAddIn_Shutdown);
}
#endregion
}
}
728x90
그리드형(광고전용)
'C# > Outlook' 카테고리의 다른 글
[C#/OUTLOOK] Inspector 인터페이스 : WordEditor 속성을 사용해 메일 쓰기 창에서 선택 텍스트 구하기 (0) | 2021.10.05 |
---|---|
[C#/OUTLOOK] Application 인터페이스 : ItemSend 이벤트에서 메일 발송 취소하기 (0) | 2021.10.05 |
[C#/OUTLOOK] Application 인터페이스 : Explorers 속성/ActiveExplorer 메소드 사용하기 (0) | 2021.10.05 |
[C#/OUTLOOK] Application 인터페이스 : Inspectors 속성/ActiveInspector 메소드 사용하기 (0) | 2021.10.05 |
[C#/OUTLOOK] Attachment 인터페이스 : PropertyAccessor 속성을 사용해 첨부 파일 표시 여부 설정하기 (0) | 2021.08.11 |
[C#/OUTLOOK] MailItem 인터페이스 : PropertyAccessor 속성을 사용해 메시지 ID 구하기 (0) | 2021.08.10 |
[C#/OUTLOOK] IOleWindow 인터페이스 : GetWindow 메소드를 사용해 아웃룩 윈도우 핸들 구하기 (0) | 2021.08.10 |
[C#/OUTLOOK] 누겟 설치 : Microsoft.VisualStudio.OLE.Interop (0) | 2021.08.10 |
[C#/OUTLOOK] 애드인 모듈 버전 구하기 (0) | 2021.08.10 |
[C#/OUTLOOK] Application 인터페이스 : Version 속성을 사용해 아웃룩 버전 구하기 (0) | 2021.08.10 |