Пример #1
0
        public bool PrintMessage(string EntryID, string StoreID)
        {
            _com_Outlook_Application outlook  = null;
            _com_OutlookNameSpace    session  = null;
            _com_OutlookMailItem     mailItem = null;

            try
            {
                outlook = new _com_Outlook_Application();

                session = outlook.NameSpace;
                session.Logon( );
                mailItem = session.GetItemFromID(EntryID, StoreID);

                if (mailItem != null)
                {
                    mailItem.PrintOut();
                }
                return(true);
            }
            catch (Exception exception)
            {
                ReportProblem(exception);
            }
            finally
            {
                COM_Object.ReleaseIfNotNull(mailItem);
                COM_Object.ReleaseIfNotNull(session);
                COM_Object.ReleaseIfNotNull(outlook);
            }
            return(false);
        }
Пример #2
0
 public void ForwardMessage()
 {
     try
     {
         if (_mailItem != null)
         {
             _newMail = _mailItem.Forward();
             _newMail.Display(false);
         }
     }
     catch (Exception exception)
     {
         ReportProblem(exception);
     }
 }
Пример #3
0
 public MailAction(string EntryID, string StoreID)
 {
     Guard.EmptyStringArgument(EntryID, "EntryID");
     Guard.EmptyStringArgument(StoreID, "StoreID");
     try
     {
         _entryId  = EntryID;
         _storeId  = StoreID;
         _mailItem = GetItemFromID(EntryID, StoreID);
     }
     catch (Exception exception)
     {
         ReportProblem(exception);
     }
 }
Пример #4
0
 public void ReplyMessage(IResource mail)
 {
     try
     {
         if (_mailItem != null)
         {
             _newMail = _mailItem.Reply();
             QuoteReply(mail);
             _newMail.Display(false);
         }
     }
     catch (Exception exception)
     {
         ReportProblem(exception);
     }
 }
Пример #5
0
        private bool CreateNewMessage(string subject, string body, EmailBodyFormat bodyFormat, ArrayList recipients,
                                      string[] attachments, bool useTemplatesInBody, ArrayList categories)
        {
            Settings.LoadSettings();
            OutlookGUIInit.StartAndInitializeOutlook();
            _com_Outlook_Application outlook = null;
            _com_OutlookMailItem     newMail = null;

            try
            {
                outlook         = new _com_Outlook_Application();
                newMail         = outlook.CreateNew();
                newMail.Subject = subject;

                bool validBody = !String.IsNullOrEmpty(body);

                if (useTemplatesInBody && Settings.UseSignature)
                {
                    body += "\r\n";
                    body += Settings.Signature;
                }

                if (validBody && EmailBodyFormat.Html == bodyFormat)
                {
                    try
                    {
                        newMail.BodyFormat = OlBodyFormat.olFormatHTML;
                    }
                    catch (Exception) {}
                    newMail.HTMLBody = body;
                }
                else
                if (validBody)
                {
                    try
                    {
                        newMail.BodyFormat = OlBodyFormat.olFormatPlain;
                    }
                    catch (Exception) {}
                    newMail.Body = body;
                }
                else
                if (!String.IsNullOrEmpty(body))
                {
                    newMail.Body = body;
                }

                if (recipients != null && recipients.Count > 0)
                {
                    OutlookSession.EMAPISession.AddRecipients(newMail.MAPIOBJECT, recipients);
                    if (Settings.SetCategoryFromContactWhenEmailSent && categories != null)
                    {
                        newMail.AddCategories(categories);
                    }
                }
                if (attachments != null && attachments.Length > 0)
                {
                    newMail.AddAttachments(attachments);
                }
                newMail.Display(false);
                return(true);
            }
            catch (Exception exception)
            {
                ReportProblem(exception);
            }
            finally
            {
                COM_Object.ReleaseIfNotNull(newMail);
                COM_Object.ReleaseIfNotNull(outlook);
            }
            return(false);
        }