Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
            private _com_OutlookMailItem GetItemFromID(string EntryID, string StoreID)
            {
                OutlookGUIInit.StartAndInitializeOutlook();
                _com_Outlook_Application outlook = null;
                _com_OutlookNameSpace    session = null;

                try
                {
                    outlook = new _com_Outlook_Application();
                    session = outlook.NameSpace;
                    return(session.GetItemFromID(EntryID, StoreID));
                }
                catch (Exception exception)
                {
                    ReportProblem(exception);
                }
                finally
                {
                    COM_Object.ReleaseIfNotNull(session);
                    COM_Object.ReleaseIfNotNull(outlook);
                }
                return(null);
            }
Ejemplo n.º 3
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);
        }