Inheritance: NodeXLApplicationSettingsBase
コード例 #1
0
    //*************************************************************************
    //  Constructor: ExportToEmailDialog()
    //
    /// <summary>
    /// Initializes a new instance of the <see cref="ExportToEmailDialog" />
    /// class.
    /// </summary>
    ///
    /// <param name="mode">
    /// Indicates the mode in which the dialog is being used.
    /// </param>
    ///
    /// <param name="workbook">
    /// Workbook containing the graph data.
    /// </param>
    ///
    /// <param name="nodeXLControl">
    /// NodeXLControl containing the graph.  This can be null if <paramref
    /// name="mode" /> is <see cref="DialogMode.EditOnly" />.
    /// </param>
    //*************************************************************************

    public ExportToEmailDialog
    (
        DialogMode mode,
        Microsoft.Office.Interop.Excel.Workbook workbook,
        NodeXLControl nodeXLControl
    )
    {
        Debug.Assert(workbook != null);
        Debug.Assert(nodeXLControl != null || mode == DialogMode.EditOnly);

        m_eMode = mode;
        m_oWorkbook = workbook;
        m_oNodeXLControl = nodeXLControl;
        m_oExportToEmailUserSettings = new ExportToEmailUserSettings();
        m_oPasswordUserSettings = new PasswordUserSettings();

        InitializeComponent();

        if (m_eMode == DialogMode.EditOnly)
        {
            InitializeForEditOnly();
        }

        // Instantiate an object that saves and retrieves the user settings for
        // this dialog.  Note that the object automatically saves the settings
        // when the form closes.

        m_oExportToEmailDialogUserSettings =
            new ExportToEmailDialogUserSettings(this);

        DoDataExchange(false);

        AssertValid();
    }
コード例 #2
0
        //*************************************************************************
        //  Constructor: ExportToEmailDialog()
        //
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportToEmailDialog" />
        /// class.
        /// </summary>
        ///
        /// <param name="mode">
        /// Indicates the mode in which the dialog is being used.
        /// </param>
        ///
        /// <param name="workbook">
        /// Workbook containing the graph data.
        /// </param>
        ///
        /// <param name="nodeXLControl">
        /// NodeXLControl containing the graph.  This can be null if <paramref
        /// name="mode" /> is <see cref="DialogMode.EditOnly" />.
        /// </param>
        //*************************************************************************

        public ExportToEmailDialog
        (
            DialogMode mode,
            Microsoft.Office.Interop.Excel.Workbook workbook,
            NodeXLControl nodeXLControl
        )
        {
            Debug.Assert(workbook != null);
            Debug.Assert(nodeXLControl != null || mode == DialogMode.EditOnly);

            m_eMode                      = mode;
            m_oWorkbook                  = workbook;
            m_oNodeXLControl             = nodeXLControl;
            m_oExportToEmailUserSettings = new ExportToEmailUserSettings();
            m_oPasswordUserSettings      = new PasswordUserSettings();

            InitializeComponent();

            if (m_eMode == DialogMode.EditOnly)
            {
                InitializeForEditOnly();
            }

            // Instantiate an object that saves and retrieves the user settings for
            // this dialog.  Note that the object automatically saves the settings
            // when the form closes.

            m_oExportToEmailDialogUserSettings =
                new ExportToEmailDialogUserSettings(this);

            DoDataExchange(false);

            AssertValid();
        }
コード例 #3
0
 ExportToEmailUserSettingsAreComplete
 (
     ExportToEmailUserSettings oExportToEmailUserSettings,
     String sSmtpPassword
 )
 {
     return(
         !String.IsNullOrEmpty(
             oExportToEmailUserSettings.SpaceDelimitedToAddresses)
         &&
         !String.IsNullOrEmpty(oExportToEmailUserSettings.FromAddress)
         &&
         !String.IsNullOrEmpty(oExportToEmailUserSettings.SmtpHost)
         &&
         !String.IsNullOrEmpty(oExportToEmailUserSettings.SmtpUserName)
         &&
         !String.IsNullOrEmpty(sSmtpPassword)
         );
 }
コード例 #4
0
 ExportToEmailUserSettingsAreComplete
 (
     ExportToEmailUserSettings oExportToEmailUserSettings,
     String sSmtpPassword
 )
 {
     return (
         !String.IsNullOrEmpty(
             oExportToEmailUserSettings.SpaceDelimitedToAddresses)
         &&
         !String.IsNullOrEmpty(oExportToEmailUserSettings.FromAddress)
         &&
         !String.IsNullOrEmpty(oExportToEmailUserSettings.SmtpHost)
         &&
         !String.IsNullOrEmpty(oExportToEmailUserSettings.SmtpUserName)
         &&
         !String.IsNullOrEmpty(sSmtpPassword)
         );
 }
コード例 #5
0
    TryExportToEmail
    (
        Microsoft.Office.Interop.Excel.Workbook oWorkbook,
        NodeXLControl oNodeXLControl
    )
    {
        Debug.Assert(oWorkbook != null);
        Debug.Assert(oNodeXLControl != null);

        ExportToEmailUserSettings oExportToEmailUserSettings =
            new ExportToEmailUserSettings();

        String sSmtpPassword = ( new PasswordUserSettings() ).SmtpPassword;

        if ( !ExportToEmailUserSettingsAreComplete(
            oExportToEmailUserSettings, sSmtpPassword) )
        {
            FormUtil.ShowWarning(
                "The graph can't be exported to email because all required"
                + " email options haven't been specified yet.  Go to NodeXL,"
                + " Graph, Automate to fix this."
                );

            return (false);
        }

        // Note that the workbook's name is used for the subject.

        Debug.Assert( !String.IsNullOrEmpty(oWorkbook.Name) );

        try
        {
            ( new EmailExporter() ).ExportToEmail(
                oWorkbook,
                oNodeXLControl,
                oExportToEmailUserSettings.SpaceDelimitedToAddresses.Split(' '),
                oExportToEmailUserSettings.FromAddress,
                oWorkbook.Name,
                oExportToEmailUserSettings.MessageBody,
                oExportToEmailUserSettings.SmtpHost,
                oExportToEmailUserSettings.SmtpPort,
                oExportToEmailUserSettings.UseSslForSmtp,
                oExportToEmailUserSettings.SmtpUserName,
                sSmtpPassword,
                oExportToEmailUserSettings.ExportWorkbookAndSettings,
                oExportToEmailUserSettings.ExportGraphML,
                oExportToEmailUserSettings.UseFixedAspectRatio
                );

            return (true);
        }
        catch (Exception oException)
        {
            String sMessage;

            if ( EmailExceptionHandler.TryGetMessageForRecognizedException(
                oException, out sMessage) )
            {
                FormUtil.ShowWarning(sMessage);
            }
            else
            {
                ErrorUtil.OnException(oException);
            }

            return (false);
        }
    }
コード例 #6
0
        TryExportToEmail
        (
            Microsoft.Office.Interop.Excel.Workbook oWorkbook,
            NodeXLControl oNodeXLControl
        )
        {
            Debug.Assert(oWorkbook != null);
            Debug.Assert(oNodeXLControl != null);

            ExportToEmailUserSettings oExportToEmailUserSettings =
                new ExportToEmailUserSettings();

            String sSmtpPassword = (new PasswordUserSettings()).SmtpPassword;

            if (!ExportToEmailUserSettingsAreComplete(
                    oExportToEmailUserSettings, sSmtpPassword))
            {
                FormUtil.ShowWarning(
                    "The graph can't be exported to email because all required"
                    + " email options haven't been specified yet.  Go to NodeXL,"
                    + " Graph, Automate to fix this."
                    );

                return(false);
            }

            try
            {
                (new EmailExporter()).ExportToEmail(
                    oWorkbook,
                    oNodeXLControl,
                    oExportToEmailUserSettings.SpaceDelimitedToAddresses.Split(' '),
                    oExportToEmailUserSettings.FromAddress,
                    GraphTitleCreator.CreateGraphTitle(oWorkbook),
                    oExportToEmailUserSettings.MessageBody,
                    oExportToEmailUserSettings.SmtpHost,
                    oExportToEmailUserSettings.SmtpPort,
                    oExportToEmailUserSettings.UseSslForSmtp,
                    oExportToEmailUserSettings.SmtpUserName,
                    sSmtpPassword,
                    oExportToEmailUserSettings.ExportWorkbookAndSettings,
                    oExportToEmailUserSettings.ExportGraphML,
                    oExportToEmailUserSettings.UseFixedAspectRatio
                    );

                return(true);
            }
            catch (Exception oException)
            {
                String sMessage;

                if (EmailExceptionHandler.TryGetMessageForRecognizedException(
                        oException, out sMessage))
                {
                    FormUtil.ShowWarning(sMessage);
                }
                else
                {
                    ErrorUtil.OnException(oException);
                }

                return(false);
            }
        }