728x90
반응형
728x170
▶ CustomAddIn.cs
using Microsoft.Office.Interop.Outlook;
using System;
using System.Text;
using System.Windows.Forms;
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)
{
SearchForMailAddress("example.com");
}
#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
#region 메일 주소 검색하기 - SearchForMailAddress(mailAddress)
/// <summary>
/// 메일 주소 검색하기
/// </summary>
/// <param name="mailAddress">메일 주소</param>
private void SearchForMailAddress(string mailAddress)
{
MAPIFolder contactsFilder = (MAPIFolder)Application.ActiveExplorer().Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
StringBuilder stringBuilder = new StringBuilder();
foreach(object contact in contactsFilder.Items)
{
if(contact is ContactItem)
{
ContactItem contactItem = contact as ContactItem;
if(contactItem.Email1Address != null)
{
if(contactItem.Email1Address.Contains(mailAddress))
{
stringBuilder.AppendLine($"Contact : {contactItem.FirstName} {contactItem.LastName} ({contactItem.Email1Address})");
}
}
}
}
if(!(stringBuilder.Length > 0))
{
stringBuilder.Append("No Contacts were found.");
}
MessageBox.Show(stringBuilder.ToString());
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > Outlook' 카테고리의 다른 글
[C#/OUTLOOK] _MailItem 인터페이스 : Attachments 속성을 사용해 첨부 파일 저장하기 (0) | 2021.06.16 |
---|---|
[C#/OUTLOOK] ApplicationEvents_11_Event 인터페이스 : NewMail 이벤트를 사용해 신규 메일 수신시 처리하기 (0) | 2021.06.16 |
[C#/OUTLOOK] ItemsEvents_Event 인터페이스 : ItemAdd 이벤트를 사용해 메일 수신시 처리하기 (0) | 2021.06.16 |
[C#/OUTLOOK] _MailItem 인터페이스 : Send 메소드를 사용해 메일 보내기 (0) | 2021.06.16 |
[C#/OUTLOOK] 연락처 삭제하기 (0) | 2021.06.16 |
[C#/OUTLOOK] 받은 편지함에서 하위 폴더 추가하기 (0) | 2021.06.16 |
[C#/OUTLOOK] MAPIFolder 인터페이스 : 연락처 폴더 구하기 (0) | 2021.06.16 |
[C#/OUTLOOK] MAPIFolder 인터페이스 : 연락처 폴더 구하기 (0) | 2021.06.16 |
[C#/OUTLOOK] 현재 사용자명 구하기 (0) | 2021.06.16 |
[C#/OUTLOOK] Folder 인터페이스 : 받은 편지함 폴더 구하기 (0) | 2021.06.16 |
댓글을 달아 주세요