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); }
public void Dispose() { if (_axPdf != null) { COM_Object.Release(_axPdf.GetOcx()); } }
public void AddRecipients(ArrayList recipList) { Guard.NullArgument(recipList, "recipList"); foreach (RecipInfo recInfo in recipList) { Recipient recipient = _item.Recipients.Add(recInfo.DisplayName + "<" + recInfo.Email + ">"); COM_Object.Release(recipient); } }
static public _com_OutlookExporer IsOutlookExplorerLoaded( ) { Outlook.Application outlook = null; Outlook.NameSpace nameSpace = null; _com_OutlookExporer explorer = null; _isFileNotFoundHappened = false; try { _tracer.Trace("Looking for explorer"); OutlookGUIInit.DebugMessageBox("Looking for explorer"); outlook = new Outlook.ApplicationClass(); _tracer.Trace("Outlook.Application object has been initialized properly."); nameSpace = outlook.GetNamespace("MAPI"); _tracer.Trace("Outlook.NameSpace object has been initialized properly? - " + (nameSpace != null).ToString()); explorer = new _com_OutlookExporer(outlook.ActiveExplorer()); _tracer.Trace("_com_OutlookExporer wrapper object has been initialized properly."); OutlookGUIInit.DebugMessageBox("Get ActiveExplorer"); if (explorer == null) { _tracer.Trace("Outlook explorer is not found"); } else { _tracer.Trace("Outlook explorer is found"); } } catch (FileNotFoundException exception) { _isFileNotFoundHappened = true; _tracer.TraceException(exception); } catch (COMException exception) { _tracer.TraceException(exception); } catch (InvalidComObjectException exception) { _tracer.TraceException(exception); } catch (InvalidCastException exception) { _tracer.TraceException(exception); } finally { COM_Object.Release(outlook); COM_Object.Release(nameSpace); } return(explorer); }
private void ShutdownPowerPoint( ) { if (_powerPoint == null) { return; } try { _powerPoint.Quit( ); } catch (System.Runtime.InteropServices.COMException ex) { _tracer.TraceException(ex); } catch (Exception ex) { _tracer.TraceException(ex); } COM_Object.Release(_powerPoint); }
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); }
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); }
public void Dispose() { COM_Object.ReleaseIfNotNull(_mailItem); COM_Object.ReleaseIfNotNull(_newMail); }
public void Dispose() { COM_Object.ReleaseIfNotNull(_outlookItem); }