void ICommand.Execute(object parameter)
        {
            var window = parameter as Window;

            var    message    = _viewModel.MessageText;
            var    devEmail   = _viewModel.ProblemTask.Owner.Email;
            var    outlookApp = new OutlookApp();
            string err;
            var    mail = new MailToSend
            {
                MailBody    = message,
                MailSubject = _viewModel.ProblemTask.Name + " Problem."
            };

            mail.ToReceiverList.Add(devEmail);
            if (RunTimeContext.Context.CurrentUser.Manager != null)
            {
                mail.CCReceiverList.Add(RunTimeContext.Context.CurrentUser.Manager.Email);
            }
            OutlookUtil.CreateAndSendMail(outlookApp, mail, out err);
            MessageBox.Show("The email was sent successfully!");
            if (window != null)
            {
                window.Close();
            }
        }
Exemplo n.º 2
0
        public void StartIssueSenderJob()
        {
            string        errorMsg         = string.Empty;
            string        mailBody         = string.Empty;
            string        subject          = string.Empty;
            bool          isIssueFileExist = false;
            List <string> attachedFileList = GetAttachedFileList(out isIssueFileExist);

            if (isIssueFileExist)
            {
                mailBody = @"Dear  All ,
 
 
There are one file for CBBC and 2 files for further issue today.   
 
Should you have any questions, please feel free to contact me.  ";
            }

            else
            {
                mailBody = @"Dear  All ,
 
 
There are one file for CBBC and no files for further issue today.   
 
Should you have any questions, please feel free to contact me.  ";
            }

            subject = "Daily files from East Asis " + MiscUtil.ParseDateTimeWithBlank(DateTime.Now) + " (HONG KONG)";

            using (OutlookApp app = new OutlookApp())
            {
                OutlookUtil.CreateAndSendMail(app, attachedFileList, subject, configObj.ISSUE_SENDER_CONFIG.TO_TYPE_RECIPIENTS, configObj.ISSUE_SENDER_CONFIG.CC_TYPE_RECIPIENTS, mailBody, out errorMsg);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            OutlookUtil outlookUtil = OutlookUtil.GetInstance();


            List <UserAddressBook> testList = new List <UserAddressBook>();


            UserAddressBook test1 = new UserAddressBook()
            {
                UserName   = "******",
                Department = "测试部门1",
                Email      = "*****@*****.**",
                Mobile     = "13800000001",
                SubPhone   = "001"
            };

            UserAddressBook test2 = new UserAddressBook()
            {
                UserName   = "******",
                Department = "测试部门2",
                Email      = "*****@*****.**",
                Mobile     = "13800000002",
                SubPhone   = "002"
            };


            testList.Add(test1);
            testList.Add(test2);



            Console.WriteLine("将测试数据写入 Outlook 地址簿!");
            outlookUtil.WriteAddressBookList(testList);



            Console.WriteLine("从 Outlook 地址簿读取数据!");
            List <UserAddressBook> newList = outlookUtil.ReadAddressBookList();



            Console.WriteLine("向前面获取的 用户信息,发送电子邮件!");
            outlookUtil.SendMailToUserList(newList);



            Console.WriteLine("处理完毕,按回车键退出!");
            Console.ReadLine();
        }
Exemplo n.º 4
0
        public void DragEnter(IOleDataObject pDataObj, uint grfKeyState, IOlePoint pt, ref uint pdwEffect)
        {
            if ((OutlookDrop != null) && OutlookUtil.IsOutlookItem(pDataObj))
            {
                m_CurrentObject = pDataObj;
                pdwEffect       = DragDropUtil.DRAGDROP_LINK;
            }
            else if (m_DefaultDropTarget != null)
            {
                m_DefaultDropTarget.DragEnter(pDataObj, grfKeyState, pt, pdwEffect);

                if (pdwEffect != DragDropUtil.DRAGDROP_NONE)
                {
                    pdwEffect = DragDropUtil.DRAGDROP_LINK;
                }
            }
        }
        public void StartAdditionalRicSenderJob()
        {
            string errorMsg = string.Empty;
            //FM READY_2 CBBC  15 WARRANTS  1 NAME CHANGE  2 PTs.msg
            string subject = "FM READY_ ";

            subject += GetAdditionalRicNumStr(configObj.CBBC_FILE_PATH);
            subject += " CBBC  ";
            subject += GetAdditionalRicNumStr(configObj.WARRANT_FILE_PATH);
            subject += " WARRANTS  ";
            subject += configObj.NAME_CHANGE_INFO;

            using (OutlookApp app = new OutlookApp())
            {
                OutlookUtil.CreateAndSendMail(app, subject, configObj.TO_TYPE_RECIPIENTS, configObj.CC_TYPE_RECIPIENTS, "", out errorMsg);
            }
            Logger.Log(errorMsg);
        }
        //Send mail with CB Announcement text file attached.
        private void sendMail()
        {
            string        errMsg   = string.Empty;
            List <string> fileList = new List <string>();
            string        mailSuj  = "TW CB PRICE " + DateTime.Now.ToString("ddMMMyy").ToUpper();
            string        mailBody = @"Hi, 
 
Grateful your help to insert attached  file for real-time data correction asap.  
Thank you in advance. 
 
Regards";

            if (fileList.Count != 0)
            {
                using (OutlookApp app = new OutlookApp())
                {
                    OutlookUtil.CreateAndSendMail(app, cbAnnouncementFileList, mailSuj, configObj.TO_TYPE_RECIPIENTS, configObj.CC_TYPE_RECIPIENTS, mailBody, out errMsg);
                }
            }
        }
Exemplo n.º 7
0
        public void StartFMSenderJob()
        {
            string        errorMsg         = string.Empty;
            List <string> attachedFileList = new List <string>();
            string        subject          = "HKFM_";

            subject += MiscUtil.ParseDateTime(DateTime.Now);
            subject += "_2";
            string mailBody = @"Hi, 

Please find  the FM for today in the attached folder.

Should you have any questions, please feel free to contact me.  ";

            string attachedFile = GetFMFileZip(configObj.FM_SENDER_CONFIG.FM_FILE_DIR);

            attachedFileList.Add(attachedFile);
            using (OutlookApp app = new OutlookApp())
            {
                OutlookUtil.CreateAndSendMail(app, attachedFileList, subject, configObj.FM_SENDER_CONFIG.TO_TYPE_RECIPIENTS, configObj.FM_SENDER_CONFIG.CC_TYPE_RECIPIENTS, mailBody, out errorMsg);
            }
        }
Exemplo n.º 8
0
        public void StartDelistSenderJob()
        {
            string errorMsg = string.Empty;
            string subject  = "HKFM_";

            subject += ParseDateTime(GetNextBusinessDay(configObj.HOLIDAY_COUNT));
            subject += "_1";

            string mailBody = @"Dear  all, 
 
 
Please find attached today’s last minute FM.  
 
Should you have any questions, please feel free to contact me.";

            List <string> attachedFileList = GetDelistFileList(configObj.LAST_DELIST_FILE_DIR);

            using (OutlookApp app = new OutlookApp())
            {
                OutlookUtil.CreateAndSendMail(app, attachedFileList, subject, configObj.TO_TYPE_RECIPIENTS, configObj.CC_TYPE_RECIPIENTS, mailBody, out errorMsg);
            }
            Logger.Log(errorMsg);
        }
Exemplo n.º 9
0
        /// <summary>
        ///  Get source files according to the file name keyword
        /// </summary>
        /// <param name="item"></param>
        /// <param name="keyword"></param>
        /// <param name="fileSavedDir"></param>
        /// <returns></returns>
        public static string GetTargetAttachedFile(MailItem item, string keyword, string fileSavedDir)
        {
            string sourceFile = string.Empty;

            try
            {
                List <string> attachedFileList = OutlookUtil.DownloadAttachments(item, keyword, null, fileSavedDir);
                if (attachedFileList == null || attachedFileList.Count == 0)
                {
                    throw new System.Exception(string.Format("Can't find the file name of which contains {0}", keyword));
                }
                if (attachedFileList.Count > 1)
                {
                    throw new System.Exception(string.Format("There're more than 1 files found name of which contails {0}", keyword));
                }
                sourceFile = attachedFileList[0];
            }
            catch (System.Exception ex)
            {
                throw new System.Exception(string.Format("Error found: {0}", ex.Message));
            }
            return(sourceFile);
        }
Exemplo n.º 10
0
        public void Drop(IOleDataObject pDataObj, uint grfKeyState, IOlePoint pt, ref uint pdwEffect)
        {
            if (m_CurrentObject == pDataObj)
            {
                try
                {
                    var outlook   = new Application();
                    var selection = outlook.ActiveExplorer().Selection;

                    if ((selection != null) && (selection.Count >= 1))
                    {
                        var title = "";
                        var id    = "";

                        var item = selection[1];

                        if (item is MailItem)
                        {
                            title = (item as MailItem).Subject;
                            id    = (item as MailItem).EntryID;
                        }
                        else if (item is ContactItem)
                        {
                            title = (item as ContactItem).Subject;
                            id    = (item as ContactItem).EntryID;
                        }
                        else if (item is JournalItem)
                        {
                            title = (item as JournalItem).Subject;
                            id    = (item as JournalItem).EntryID;
                        }
                        else if (item is TaskItem)
                        {
                            title = (item as TaskItem).Subject;
                            id    = (item as TaskItem).EntryID;
                        }
                        else if (item is NoteItem)
                        {
                            title = (item as NoteItem).Subject;
                            id    = (item as NoteItem).EntryID;
                        }
                        else if (item is AppointmentItem)
                        {
                            title = (item as AppointmentItem).Subject;
                            id    = (item as AppointmentItem).EntryID;
                        }

                        if (!String.IsNullOrEmpty(title) && !String.IsNullOrEmpty(id))
                        {
                            var url = OutlookUtil.FormatItemAsUrl(id);
                            OutlookDrop(this, title, url);

                            pdwEffect = DragDropUtil.DRAGDROP_LINK;
                        }
                    }
                }
                catch (System.Exception /*e*/)
                {
                    pdwEffect = DragDropUtil.DRAGDROP_NONE;
                }
            }
            else if (m_DefaultDropTarget != null)
            {
                m_DefaultDropTarget.Drop(pDataObj, grfKeyState, pt, pdwEffect);

                if (pdwEffect != DragDropUtil.DRAGDROP_NONE)
                {
                    pdwEffect = DragDropUtil.DRAGDROP_LINK;
                }
            }

            m_CurrentObject = null;
        }