/************************************************************************ * Name: : AfterSendingItem * Description : Occurs after sending an item ************************************************************************/ private void AfterSendingItem(object item) { bool sent = false; // 4 items that contains send action if (item is Outlook.MailItem) { Outlook.MailItem mailItem = (Outlook.MailItem)item; sent = mailItem.Sent; } else if (item is Outlook.MeetingItem) { Outlook.MeetingItem meetingItem = (Outlook.MeetingItem)item; sent = meetingItem.Sent; } else if (item is Outlook.MobileItem) { Outlook.MobileItem mobileItem = (Outlook.MobileItem)item; sent = mobileItem.Sent; } else if (item is Outlook.SharingItem) { Outlook.SharingItem sharingItem = (Outlook.SharingItem)item; sent = sharingItem.Sent; } //TODO: }
/// <summary> /// 送信者の情報(Dto)を取得する /// </summary> /// <param name="Item">Outlookアイテムオブジェクト</param> /// <returns>送信者の宛先情報インスタンス(送信者が取得できない場合null)</returns> public static RecipientInformationDto GetSenderInfomation(object Item) { if (Item is Outlook.MailItem) { Outlook.MailItem mail = (Item as Outlook.MailItem); return(GetSenderInformation(mail)); } else if (Item is Outlook.MeetingItem) { Outlook.MeetingItem meeting = Item as Outlook.MeetingItem; return(GetSenderInformation(meeting)); } else if (Item is Outlook.AppointmentItem) { Outlook.AppointmentItem appointment = Item as Outlook.AppointmentItem; return(GetSenderInformation(appointment)); } else if (Item is Outlook.ReportItem) { Outlook.ReportItem report = Item as Outlook.ReportItem; return(GetSenderInformation(report)); } else if (Item is Outlook.SharingItem) { Outlook.SharingItem sharing = Item as Outlook.SharingItem; return(GetSenderInformation(sharing)); } else if (Item is Outlook.TaskItem) { Outlook.TaskItem task = Item as Outlook.TaskItem; return(GetSenderInformation(task)); } else if (Item is Outlook.TaskRequestItem) { Outlook.TaskRequestItem taskRequest = Item as Outlook.TaskRequestItem; return(GetSenderInformation(taskRequest)); } else if (Item is Outlook.TaskRequestAcceptItem) { Outlook.TaskRequestAcceptItem taskRequestAcceptItem = Item as Outlook.TaskRequestAcceptItem; string mailHeader = GetMailHeader(taskRequestAcceptItem.PropertyAccessor); return(GetSenderInformationFromMailHeader(mailHeader)); } else if (Item is Outlook.TaskRequestDeclineItem) { Outlook.TaskRequestDeclineItem taskRequestDeclineItem = Item as Outlook.TaskRequestDeclineItem; string mailHeader = GetMailHeader(taskRequestDeclineItem.PropertyAccessor); return(GetSenderInformationFromMailHeader(mailHeader)); } else { throw new NotSupportedException("未対応のOutook機能です。"); } }
/// <summary> /// SharingItemの送信者情報(Dto)を取得する /// </summary> /// <param name="Item">SharingItemオブジェクト</param> /// <returns>送信者の宛先情報DTO(送信者が取得できない場合null)</returns> private static RecipientInformationDto GetSenderInformation(Outlook.SharingItem item) { if (item.SenderEmailAddress == null) { return(GetCurrentUserInformation()); } Outlook.Recipient recipient = Globals.ThisAddIn.Application.Session.CreateRecipient(item.SenderEmailAddress); Outlook.AddressEntry addressEntry = null; Outlook.ExchangeUser exchUser = null; if (recipient != null) { addressEntry = recipient.AddressEntry; exchUser = getExchangeUser(addressEntry); } RecipientInformationDto senderInformation = null; // 送信者のExchangeUserが取得できた場合 if (exchUser != null) { senderInformation = new RecipientInformationDto(exchUser.Name, exchUser.Department, exchUser.CompanyName, FormatJobTitle(exchUser.JobTitle), Outlook.OlMailRecipientType.olOriginator); } // ExchangeUserが取得できないが、送信者情報は取得できた場合 else { string displayName; if (item.SenderName != null && !Utility.IsEmailAddress(item.SenderName)) { displayName = FormatDisplayNameAndAddress(item.SenderName, item.SenderEmailAddress); } else if (recipient != null && !Utility.IsEmailAddress(recipient.Name)) { displayName = GetDisplayNameAndAddress(recipient); } else if (addressEntry != null) { displayName = FormatDisplayNameAndAddress(addressEntry.Name, addressEntry.Address); } else { displayName = FormatDisplayNameAndAddress(item.SenderName, item.SenderEmailAddress); } senderInformation = new RecipientInformationDto(displayName, Outlook.OlMailRecipientType.olOriginator); } return(senderInformation); }
/// <summary> /// SharingItemから、宛先(Recipient)のリスト取得する /// </summary> /// <param name="Item">SharingItemオブジェクト</param> /// <returns>List<Outlook.Recipient></returns> private static List <Outlook.Recipient> GetRecipientList(Outlook.SharingItem item) { Outlook.Recipients recipients = item.Recipients; List <Outlook.Recipient> recipientsList = new List <Outlook.Recipient>(); //AppointmentItemの場合1番目には送信者、2番目から宛先が入っている for (int i = 1; i <= recipients.Count; i++) { recipientsList.Add(recipients[i]); } return(recipientsList); }
/// <summary> /// アイテムから、宛先(Recipient)のリスト取得する /// </summary> /// <param name="Item">Outlookアイテムオブジェクト</param> /// <param name="type">アイテムの種類</param> /// <param name="IgnoreMeetingResponse">会議招集の返信かどうか</param> /// <returns>Recipientsインスタンス(会議招集の返信や、MailItem,MeetingItem,AppointmentItemでない場合null)</returns> public static List <Outlook.Recipient> GetRecipients(object Item, ref OutlookItemType type, bool IgnoreMeetingResponse = false) { // MailItemの場合 if (Item is Outlook.MailItem) { type = OutlookItemType.Mail; Outlook.MailItem mail = Item as Outlook.MailItem; return(GetRecipientList(mail)); } // MeetingItemの場合 else if (Item is Outlook.MeetingItem) { Outlook.MeetingItem meeting = Item as Outlook.MeetingItem; // 会議招集の返信の場合 // "IPM.Schedule.Meeting.Resp.Neg"; // "IPM.Schedule.Meeting.Resp.Pos"; // "IPM.Schedule.Meeting.Resp.Tent"; if (meeting.MessageClass.Contains("IPM.Schedule.Meeting.Resp.")) { type = OutlookItemType.MeetingResponse; // 会議招集の返信をする場合、宛先確認画面が表示されないようnullを返す if (IgnoreMeetingResponse) { return(null); } else { return(GetRecipientList(meeting)); } } // 会議出席依頼を送信する場合など else { type = OutlookItemType.Meeting; return(GetRecipientList(meeting)); } } // AppointmentItemの場合(編集中/送信されていない状態でトレイにある会議招集メール、開催者が取り消した会議のキャンセル通知(自分承認済み)) else if (Item is Outlook.AppointmentItem) { type = OutlookItemType.Appointment; Outlook.AppointmentItem appointment = Item as Outlook.AppointmentItem; return(GetRecipientList(appointment)); } else if (Item is Outlook.SharingItem) { type = OutlookItemType.Sharing; Outlook.SharingItem sharing = Item as Outlook.SharingItem; return(GetRecipientList(sharing)); } else if (Item is Outlook.ReportItem) { type = OutlookItemType.Report; Outlook.ReportItem report = Item as Outlook.ReportItem; return(GetRecipientList(report)); } else if (Item is Outlook.TaskItem) { return(null); //type = OutlookItemType.Task; //Outlook.TaskItem task = Item as Outlook.TaskItem; //return GetRecipientList(task); } else if (Item is Outlook.TaskRequestItem) { return(null); //type = OutlookItemType.Task; //Outlook.TaskRequestItem taskRequest = Item as Outlook.TaskRequestItem; //return GetRecipientList(taskRequest); } else if (Item is Outlook.TaskRequestAcceptItem) { return(null); //type = OutlookItemType.TaskRequestResponse; //Outlook.TaskRequestAcceptItem taskRequestAccept = Item as Outlook.TaskRequestAcceptItem; //return GetRecipientList(taskRequestAccept); } else if (Item is Outlook.TaskRequestDeclineItem) { return(null); //type = OutlookItemType.TaskRequestResponse; //Outlook.TaskRequestDeclineItem taskRequestDecline = Item as Outlook.TaskRequestDeclineItem; //return GetRecipientList(taskRequestDecline); } throw new NotSupportedException("未対応のOutlook機能です。"); }