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);
}
}