첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

TestProject.zip
3.97MB

▶ 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
그리드형(광고전용)
Posted by icodebroker
,