public static ResultadoTransaccion MailEnBorrador(string toValue, string subjectValue, string bodyValue) { ResultadoTransaccion res = new ResultadoTransaccion(); try { oApp = new Application(); oNameSpace = oApp.GetNamespace("MAPI"); oOutboxFolder = oNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderDrafts); _MailItem oMailItem = (_MailItem)oApp.CreateItem(OlItemType.olMailItem); oMailItem.To = toValue; oMailItem.Subject = subjectValue; oMailItem.Body = bodyValue; //oMailItem.SaveSentMessageFolder = oOutboxFolder; oMailItem.BodyFormat = OlBodyFormat.olFormatRichText; oMailItem.Save(); res.Estado = Enums.EstadoTransaccion.Aceptada; } catch (Exception ex) { res.Descripcion = ex.Message; res.Estado = Enums.EstadoTransaccion.Rechazada; Log.EscribirLog(ex.Message); } return(res); }
public async void Initialise(MailItem selectedMailItem) { IssueTitle = selectedMailItem.Subject; IssueDescription = string.Format("Reported by email from {0} at {1}\r\n\r\n{2}", selectedMailItem.SenderName, selectedMailItem.ReceivedTime.ToString("U"), selectedMailItem.Body); currentMailItem = selectedMailItem; if (Repositories.Count > 0) { return; } if (githubApi.Context.Authorization == null || githubApi.Context.Authorization == Authorization.Anonymous) { githubApi.Context.Authorize(new Authorization { Id = settings.AuthorisationId, Token = settings.AuthToken }); } var repos = await new MyReposApi(githubApi.Context).GetMyRepositories(); await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { foreach (var repository in repos.OrderBy(r => r.FullName)) { Repositories.Add(new RepositoryModel(repository)); } }); }
/// <summary> /// GetContent callback /// </summary> /// <param name="mailItem">The mail item.</param> /// <returns></returns> public async Task <string> GetContentWithPosibleMailItemAsync(_MailItem mailItem) { // if we have no categories then something is 'broken' // we want the user to be able to add categories, so just show the default. if (_engine.Categories.Count == 0) { return(BuildMenu(BuildCommonMenus())); } // create the menu xml var menu = new StringBuilder(); // add all the categories. menu.Append(await BuildCategoriesMenusAsync(mailItem).ConfigureAwait(false)); // add a separator menu.Append(BuildMenuSeparator(menu)); // show the email details // but only if we have selected one email. if (mailItem != null) { menu.Append(BuildMailItemMenu()); } // add a separator menu.Append(BuildMenuSeparator(menu)); // add the common items. menu.Append(BuildCommonMenus()); return(BuildMenu(menu)); }
/// <summary> /// Envoi un email de confirmation de la mission. /// </summary> /// <param name="_acceptInformations">Informations de l'intérimaire</param> /// <param name="_avaibilityID">ID avibility</param> private static void AcceptEmail(List <string> _acceptInformations, string _avaibilityID) { List <string> acceptInformations = _acceptInformations; // Vérifie le contenu de la liste. if (IsCorrectList(acceptInformations)) { // Crée un message de confirmation d'accepation de mission. List <string> bodyMessage = CreateBodyMessage(SentOffer_Code.Default.TemplateAcceptPath, acceptInformations); // Vérifie le contenu du corps de message. if (IsCorrectList(bodyMessage)) { _MailItem message = CreateMessage(bodyMessage); // Vérifie la création du message, l'envoi de l'email de confirmation et l'enregistrement de l'acceptation de mission. if (IsCreateMessage(message) && IsSentEmail(message) && InterimDatabase.SetStateMission(acceptInformations[0], 1)) { // Affiche un message de réussite de l'envoi de l'email. MessageBox.Show(SentOffer_Val.Default.EmailSent, SentOffer_Val.Default.InformationTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { // Affiche un message d'erreur. MessageBox.Show(SentOffer_Val.Default.NullSendEmail, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { // Affiche un message d'erreur. MessageBox.Show(SentOffer_Err.Default.CreateMessage, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public async void Initialise(MailItem selectedMailItem) { IssueTitle = selectedMailItem.Subject; IssueDescription = string.Format("Reported by email from {0} at {1}\r\n\r\n{2}", selectedMailItem.SenderName, selectedMailItem.ReceivedTime.ToString("U"), selectedMailItem.Body); currentMailItem = selectedMailItem; if (Repositories.Count > 0) return; if (githubApi.Context.Authorization == null || githubApi.Context.Authorization == Authorization.Anonymous) { githubApi.Context.Authorize(new Authorization { Id = settings.AuthorisationId, Token = settings.AuthToken }); } var repos = await new MyReposApi(githubApi.Context).GetMyRepositories(); await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { foreach (var repository in repos.OrderBy(r => r.FullName)) { Repositories.Add(new RepositoryModel(repository)); } }); }
/// <summary> /// Gets the property value for a <see cref="_MailItem">_MailItem</see> user property. /// </summary> /// <typeparam name="T">Type of property</typeparam> /// <param name="mailItem">The contact item.</param> /// <param name="name">The name of the user property.</param> /// <param name="type">The type of the user property.</param> /// <param name="create">if set to <c>false</c> the property will not be created if it doesn't exist.</param> /// <param name="converter">The converter to use to convert the object to.</param> /// <param name="defaultValue">The default value to use if user property not found.</param> /// <returns>User property value or default</returns> public static T GetPropertyValue <T>(this _MailItem mailItem, string name, OlUserPropertyType type, bool create, Func <object, T> converter, T defaultValue) { using (var userProperties = mailItem.UserProperties.WithComCleanup()) { return(GetPropertyValue(userProperties.Resource, name, type, create, converter, defaultValue)); } }
/// <summary> /// Sets the user property value. /// </summary> /// <typeparam name="T">Type of property</typeparam> /// <param name="mailItem">The mail item.</param> /// <param name="name">The name of the user property to set.</param> /// <param name="type">The type of the user property.</param> /// <param name="value">The value to set.</param> /// <param name="addToFolder">if set to <c>true</c> add to containing folder. Enables search/display column for user property.</param> public static void SetPropertyValue <T>(this _MailItem mailItem, string name, OlUserPropertyType type, T value, bool addToFolder) { using (var userProperties = mailItem.UserProperties.WithComCleanup()) { SetPropertyValue(userProperties.Resource, name, type, value, addToFolder); } }
/// <summary> /// Categorise a mail item to a certain category it. /// </summary> /// <param name="mailItem">The mail item we wish to categorise</param> /// <param name="id">The category id number we want to set this to.</param> /// <returns>boolean success or not.</returns> private async Task <bool> ClassifyMailAsync(_MailItem mailItem, uint id) { // we know this is a user selected item // so we can get the weight from the options. var entryIdItem = mailItem.EntryID; return(await _mailProcessor.ClassifyAsync(entryIdItem, id, _engine.Options.UserWeight).ConfigureAwait(false)); }
static void Main(string[] args) { var parser = new CommandLineParser.CommandLineParser(); var send = new SwitchArgument('s', "send", "Whether to automatically send the messages or not", false); var template = new ValueArgument <string>('t', "template", "The path to the html template (title = subject)"); var csv = new ValueArgument <string>('c', "csv", "The path to the CSV file"); parser.Arguments.Add(template); parser.Arguments.Add(csv); parser.Arguments.Add(send); try { parser.ParseCommandLine(args); parser.ShowParsedArguments(); } catch (System.Exception exc) { Console.WriteLine(exc.Message); return; } var reader = new CsvReader(new StreamReader(new FileStream(csv.Value, FileMode.Open))); var content = File.ReadAllText(template.Value); var title = XElement.Parse(content).Descendants("title").First().Value; while (reader.Read()) { var body = content; foreach (var f in reader.FieldHeaders) { body = body.Replace("{" + f.ToLower() + "}", reader.GetField <string>(f)); } var app = new Application(); var ns = app.GetNamespace("MAPI"); ns.Logon(null, null, false, false); var outbox = ns.GetDefaultFolder(OlDefaultFolders.olFolderOutbox); _MailItem message = app.CreateItem(OlItemType.olMailItem); message.To = reader.GetField <string>(reader.FieldHeaders.Single(fh => string.Equals(fh, "email", StringComparison.InvariantCultureIgnoreCase))); message.Subject = title; message.BodyFormat = OlBodyFormat.olFormatHTML; message.HTMLBody = body; message.SaveSentMessageFolder = outbox; if (send.Value) { message.Send(); } else { message.Save(); } } }
private void PopulateDialog(IConfirmationView view, _MailItem mailItem) { view.AccountName = mailItem.SendUsingAccount.DisplayName; view.To = AddressSplitter.SplitAddresses(mailItem.To); view.CC = AddressSplitter.SplitAddresses(mailItem.CC); view.BCC = AddressSplitter.SplitAddresses(mailItem.BCC); view.NumberOfAttachments = mailItem.Attachments.Count; view.Sender = string.Format("{0} [{1}]", mailItem.SendUsingAccount.UserName, mailItem.SendUsingAccount.SmtpAddress); view.Subject = mailItem.Subject; }
private static IEnumerable <string> Attach(AttachmentCollection attachments, _MailItem oMsg) { var attachmentIndex = 0; var filenames = new List <string>(); foreach (var attachment in attachments) { filenames.Add(Path.GetTempFileName()); File.WriteAllBytes(filenames.Last(), attachment.ContentStream.ToByteArray()); oMsg.Attachments.Add(filenames.Last(), OlAttachmentType.olByValue, attachmentIndex++, attachment.Name); } return(filenames); }
/// <summary> /// Vérifie le contenu du message. /// </summary> /// <param name="_message">Message</param> /// <returns>Boolean : True -> Message non null. False -> Message null.</returns> private static bool IsCreateMessage(_MailItem _message) { _MailItem message = _message; bool isCorrectCreateMessage = (message != null); // Vérifie le contenu du message. if (isCorrectCreateMessage) { return(true); } // Affichage d'un message d'erreur. MessageBox.Show(SentOffer_Val.Default.NullMessage, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); }
/// <summary> /// Vérifie l'envoi de la proposition de mission. /// </summary> /// <param name="_message">Message</param> /// <returns>Boolean : True -> Réussite de l'envoi de l'email. False -> Echec de l'envoi de l'email</returns> private static bool IsSentEmail(_MailItem _message) { try { _MailItem message = _message; message.Send(); return(true); } catch { // Affichage d'un message d'erreur. MessageBox.Show(SentOffer_Err.Default.IsSentEmail, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
private string GetSenderSMTPAddress(_MailItem mail) { if (mail == null) { throw new ArgumentNullException(); } if (mail.SenderEmailType != "EX") { return(mail.SenderEmailAddress); } var sender = mail.Sender; return(GetAddress(sender)); }
public bool ExportSessions(string sExportFormat, Session[] oSessions, Dictionary <string, object> dictOptions, EventHandler <ProgressCallbackEventArgs> evtProgressNotifications) { IList <string> attachments = new List <string>(); foreach (Session item in oSessions) { string file = Path.Combine(Path.GetTempPath(), item.id + ".txt"); File.WriteAllText(file, item.ToString()); attachments.Add(file); XmlDocument doc = new XmlDocument(); try { doc.Load(new MemoryStream(item.RequestBody)); file = Path.Combine(Path.GetTempPath(), "request_" + item.id + ".xml"); doc.Save(file); attachments.Add(file); doc.Load(new MemoryStream(item.ResponseBody)); file = Path.Combine(Path.GetTempPath(), "response_" + item.id + ".xml"); doc.Save(file); attachments.Add(file); } catch { //dann nicht :-); } } Application oApp = new Application(); _MailItem oMailItem = (_MailItem)oApp.CreateItem(OlItemType.olMailItem); foreach (var item in attachments) { oMailItem.Attachments.Add((object)item, OlAttachmentType.olEmbeddeditem, 1, (object)"Attachment"); } oMailItem.Display(); return(true); }
/// <summary> /// Build rows of available categories. /// </summary> /// <param name="mailItem"></param> /// <returns></returns> private async Task <StringBuilder> BuildCategoriesMenusAsync(_MailItem mailItem) { // do we know the current category? var currentCategory = mailItem == null ? null : _mailProcessor.GetCategoryFromMailItem(mailItem); // get the current category if? var currentCategoryId = (int?)currentCategory?.Id ?? -1; // try and guess the new category var guessCategoryResponse = await GuessPosibleCategory(mailItem, currentCategoryId, _engine.Categories.List).ConfigureAwait(false); var proposedCurrentCategoryId = guessCategoryResponse?.CategoryId ?? -1; var menu = new StringBuilder(); // and create a menu for all of them. foreach (var category in _engine.Categories.List) { var safeLabel = category.XmlName.Replace("&", "&&"); var getImage = ""; if (currentCategoryId == category.Id && proposedCurrentCategoryId == category.Id) { // best guess selected image. getImage = @"getImage=""GetImageBoth"""; } else if (currentCategoryId == category.Id) { getImage = @"getImage=""GetImageSelected"""; } else if (proposedCurrentCategoryId == category.Id) { getImage = @"getImage=""GetImageMaybe"""; } //else //{ // no image //} // best guess selected image. menu.Append( $@"<button id=""myoddweb.classifier_manage_{category.Id}"" label=""{safeLabel}"" onAction=""OnSelectCategory"" {getImage}/>" ); } return(menu); }
private static IEnumerable <Contract> GetContracts(_MailItem mail) { var attachment = mail.Attachments[1]; var strFilePath = Path.Combine(Path.GetTempPath(), attachment.FileName); var arrachmentType = attachment.Type; //var path = attachment.GetTemporaryFilePath(); var attachmentClass = attachment.Class; var attachmentSession = attachment.Session; if (File.Exists(strFilePath)) { try { File.Delete(strFilePath); } catch (Exception e) { MessageBox.Show(string.Format("附件临时文件{0}已被占用请删除后再执行同步操作.", strFilePath)); var trace = e.StackTrace; return(new List <Contract>()); } } attachment.SaveAsFile(strFilePath); var app = new Excel.Application(); Excel.Workbook excelWorkbook = app.Workbooks.Open(strFilePath, 0, false, 5, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value, true, false, System.Reflection.Missing.Value, false, false, false); // //app.Visible = true; var result = ContractCollector.GetContracts(app); app.Quit(); return(result); }
public static void OpenEmail(string address) { if (IsOutLookOpen() == false) { Helpers.DefaultMessegeBox("תוכנת האאוטלוק סגורה, אנא פתח אותה", "IBJJL", System.Windows.Forms.MessageBoxIcon.Stop); return; } try { Application oApp = new Application(); _MailItem oMailItem = (MailItem)oApp.CreateItem(OlItemType.olMailItem); oMailItem.To = address; oMailItem.Subject = "הודעה מ IBJJL"; oMailItem.Display(true); } catch { } }
/// <summary> /// Categorise a mail item to a certain category it. /// </summary> /// <param name="mailItem">The mail item we wish to categorise</param> /// <param name="id">The category id number we want to set this to.</param> /// <returns>boolean success or not.</returns> async private Task<myoddweb.classifier.Errors> ClassifyMailAsync( _MailItem mailItem, uint id ) { var categories = GetAllCategories(); // we know this is a user selected item // so we can get the weight from the options. return await categories.ClassifyAsync(mailItem, id, _options.UserWeight).ConfigureAwait(false); }
public void VerifyProtectDialogIsShownAndCancelIt(_MailItem mailItem) { OutlookSecurity OutlookBarGroup = new OutlookSecurity(); OutlookBarGroup.DismissSecurityDialog(); Assert.IsTrue(m_windowEnumerator.BackgroundWaitForProtectDialog_PressEscapeKey(30000), "Could not schedule dialog handling for the test"); mailItem.Send(); Assert.IsTrue(WaitAMinuteWindowEnumeratorToFinish(), "Seem to have locked up somewhere"); Assert.IsTrue(m_windowEnumerator.LastBackgroundActionCompletedOK(), "Did not use the dialog properly during the send"); m_windowEnumerator.CollectWindowDetails(); Assert.IsFalse(m_windowEnumerator.ProtectDialogIsShowing(), "The dialog should have gone now"); }
public void VerifyMailIsSentWithoutProtectDialog(_MailItem mailItem) { OutlookSecurity OutlookBarGroup = new OutlookSecurity(); OutlookBarGroup.DismissSecurityDialog(); Assert.IsTrue(m_windowEnumerator.BackgroundWaitForProtectDialog_PressDefaultButton(15000), "Could not schedule dialog handling for the test"); mailItem.Send(); Assert.IsTrue(WaitAMinuteWindowEnumeratorToFinish(), "Seem to have locked up somewhere"); Assert.IsFalse(m_windowEnumerator.LastBackgroundActionCompletedOK(), "We appear to be blocking a B9 e-mail"); m_windowEnumerator.CollectWindowDetails(); Assert.IsFalse(m_windowEnumerator.ProtectDialogIsShowing(), "The dialog should not be shown at all"); }
private static IEnumerable<Contract> GetContracts(_MailItem mail) { var attachment = mail.Attachments[1]; var strFilePath = Path.Combine(Path.GetTempPath(), attachment.FileName); var arrachmentType = attachment.Type; //var path = attachment.GetTemporaryFilePath(); var attachmentClass = attachment.Class; var attachmentSession = attachment.Session; if (File.Exists(strFilePath)) { try { File.Delete(strFilePath); } catch (Exception e) { MessageBox.Show(string.Format("附件临时文件{0}已被占用请删除后再执行同步操作.", strFilePath)); var trace = e.StackTrace; return new List<Contract>(); } } attachment.SaveAsFile(strFilePath); var app = new Excel.Application(); Excel.Workbook excelWorkbook = app.Workbooks.Open(strFilePath, 0, false, 5, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value, true, false, System.Reflection.Missing.Value, false, false, false); // //app.Visible = true; var result = ContractCollector.GetContracts(app); app.Quit(); return result; }
/// <summary> /// Guess the posible new category id /// </summary> /// <param name="mailItem">the mail item itself.</param> /// <param name="categories">the categories tool we will use to re-categorise</param> /// <param name="currentCategoryId">The current value of the category</param> /// <returns>Categories.CategorizeResponse the new id or -1 if we don't know.</returns> protected async Task <MailProcessor.CategorizeResponse> GuessPosibleCategory(_MailItem mailItem, int currentCategoryId, IEnumerable <Category> categories) { var guessCategoryResponse = new MailProcessor.CategorizeResponse { CategoryId = 0, WasMagnetUsed = false }; if (!_engine.Options.ReCheckIfCtrlKeyIsDown || (Control.ModifierKeys & Keys.Control) != Keys.Control) { // if we do not want to check options, then we don't want to do that. if (!_engine.Options.ReCheckCategories) { return(guessCategoryResponse); } // if we currently have a category and we only want to check the // unknown categories, then we musn't check. if (currentCategoryId != -1 && _engine.Options.CheckIfUnKnownCategory) { return(guessCategoryResponse); } } var currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; // start the wath var watch = StopWatch.Start(_engine.Logger); try { // guess where it could be going to now. if (mailItem != null) { guessCategoryResponse = await _mailProcessor.CategorizeAsync(mailItem).ConfigureAwait(false); } } catch (Exception e) { _engine.Logger.LogError(e.ToString()); // @todo we need to log that there was an issue. guessCategoryResponse = new MailProcessor.CategorizeResponse { CategoryId = 0, WasMagnetUsed = false }; } // reset the cursor. Cursor.Current = currentCursor; // add a debug message. watch.Stop(guessCategoryResponse.CategoryId != currentCategoryId ? $"My new classifying guess for this message is : {guessCategoryResponse.CategoryId} (in {{0}})" : $"My classifying guess for this message is category remains the same : {guessCategoryResponse.CategoryId} (in {{0}})"); // return what we found return(guessCategoryResponse); }
public void enviaCorreo(bool _enviar, string _recipient, List <string> _olCCrecipients, string _subject, string _body) { try { char[] chArray = new char[1] { ';' }; string[] strArray = (string[])null; // ISSUE: variable of a compiler-generated type Microsoft.Office.Interop.Outlook.Application instance = (Microsoft.Office.Interop.Outlook.Application)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("0006F03A-0000-0000-C000-000000000046"))); // ISSUE: reference to a compiler-generated field if (EnviarCorreo.\u003CenviaCorreo\u003Eo__SiteContainer6.\u003C\u003Ep__Site7 == null) { // ISSUE: reference to a compiler-generated field EnviarCorreo.\u003CenviaCorreo\u003Eo__SiteContainer6.\u003C\u003Ep__Site7 = CallSite <Func <CallSite, object, _MailItem> > .Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(_MailItem), typeof(EnviarCorreo))); } // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated method // ISSUE: variable of a compiler-generated type _MailItem mailItem = EnviarCorreo.\u003CenviaCorreo\u003Eo__SiteContainer6.\u003C\u003Ep__Site7.Target((CallSite)EnviarCorreo.\u003CenviaCorreo\u003Eo__SiteContainer6.\u003C\u003Ep__Site7, instance.CreateItem(OlItemType.olMailItem)); // ISSUE: variable of a compiler-generated type Inspector getInspector = mailItem.GetInspector; // ISSUE: variable of a compiler-generated type Recipients recipients = mailItem.Recipients; foreach (string olCcrecipient in _olCCrecipients) { if (!string.IsNullOrEmpty(olCcrecipient)) { // ISSUE: reference to a compiler-generated method // ISSUE: variable of a compiler-generated type Recipient recipient = recipients.Add(olCcrecipient); recipient.Type = 2; // ISSUE: reference to a compiler-generated method recipient.Resolve(); } } if (!string.IsNullOrEmpty(_recipient)) { strArray = _recipient.Split(chArray); } if (strArray != null && strArray.Length != 0) { foreach (string Name in strArray) { // ISSUE: reference to a compiler-generated method // ISSUE: variable of a compiler-generated type Recipient recipient = recipients.Add(Name); recipient.Type = 1; // ISSUE: reference to a compiler-generated method recipient.Resolve(); } } mailItem.Subject = _subject; mailItem.HTMLBody = _body + mailItem.HTMLBody; if (_enviar) { // ISSUE: reference to a compiler-generated method mailItem.Send(); } else { // ISSUE: reference to a compiler-generated method mailItem.Display((object)true); } } catch (Exception ex) { int num = (int)MessageBox.Show("Error durante el proceso del Envío del Correo: " + ex.Message, "Error Interno", MessageBoxButtons.OK, MessageBoxIcon.Hand); } Thread.Sleep(10000); }
public void enviaCorreo(ObservableCollection <Entidad> _olBCCRecipients, string _recipient, string _subject, string _body) { try { char[] chArray = new char[1] { ';' }; // ISSUE: variable of a compiler-generated type Microsoft.Office.Interop.Outlook.Application instance = (Microsoft.Office.Interop.Outlook.Application)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("0006F03A-0000-0000-C000-000000000046"))); // ISSUE: reference to a compiler-generated field enviaCorreo.c if (EnviarCorreo.\u003CenviaCorreo\u003Eo__SiteContainer0.\u003C\u003Ep__Site1 == null) { // ISSUE: reference to a compiler-generated field EnviarCorreo.\u003CenviaCorreo\u003Eo__SiteContainer0.\u003C\u003Ep__Site1 = CallSite <Func <CallSite, object, _MailItem> > .Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(_MailItem), typeof(EnviarCorreo))); } // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated method // ISSUE: variable of a compiler-generated type _MailItem mailItem = EnviarCorreo.\u003CenviaCorreo\u003Eo__SiteContainer0.\u003C\u003Ep__Site1.Target((CallSite)EnviarCorreo.\u003CenviaCorreo\u003Eo__SiteContainer0.\u003C\u003Ep__Site1, instance.CreateItem(OlItemType.olMailItem)); // ISSUE: variable of a compiler-generated type Inspector getInspector = mailItem.GetInspector; bool flag = true; string str1 = ""; // ISSUE: variable of a compiler-generated type Recipients recipients = mailItem.Recipients; using (IEnumerator <Entidad> enumerator = _olBCCRecipients.GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { Entidad current = enumerator.Current; if (string.IsNullOrEmpty(current.get_ENTC_EMail())) { flag = false; str1 = str1 + "* " + current.get_ENTC_NomCompleto() + Environment.NewLine; } else { string[] strArray = current.get_ENTC_EMail().Split(chArray); if (strArray != null && strArray.Length != 0) { foreach (string str2 in strArray) { if (!string.IsNullOrEmpty(str2.Trim())) { // ISSUE: reference to a compiler-generated method // ISSUE: variable of a compiler-generated type Recipient recipient = recipients.Add(str2.Trim()); recipient.Type = 3; // ISSUE: reference to a compiler-generated method recipient.Resolve(); } } } } } } if (!flag) { int num = (int)Dialogos.MostrarMensajeInformacion("Entidades sin Email", "A las siguientes Entidad no fueron incluidos para el envio de este correo por no tener un Email (Ver Detalles).", str1); } // ISSUE: reference to a compiler-generated method // ISSUE: variable of a compiler-generated type Recipient recipient1 = recipients.Add(_recipient.Trim()); // ISSUE: reference to a compiler-generated method recipient1.Resolve(); mailItem.Subject = _subject; mailItem.HTMLBody = _body + mailItem.HTMLBody; // ISSUE: reference to a compiler-generated method mailItem.Display((object)true); } catch (Exception ex) { int num = (int)MessageBox.Show("Error durante el proceso del Envío del Correo: " + ex.Message, "Error Interno", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }
/// <summary> /// GetContent callback /// </summary> /// <param name="mailItem">The mail item.</param> /// <returns></returns> public async Task<string> GetContentWithPosibleMailItem( _MailItem mailItem ) { // create the menu xml var translationsXml = new StringBuilder(@"<menu xmlns=""http://schemas.microsoft.com/office/2009/07/customui"">"); // get all the cateories. var categories = GetAllCategories(); // if we have no categories then something is 'broken' // so we do not want our menu to show. if (null == categories) { return ""; } // do we know the current category? var currentCategory = mailItem == null ? null : categories.GetCategoryFromMailItem(mailItem); // get the current category if? var currentCategoryId = currentCategory == null ? -1 : (int)currentCategory.Id; // try and guess the new category var guessCategoryResponse = await GuessPosibleCategory(mailItem, currentCategoryId, categories).ConfigureAwait(false); // and create a menu for all of them. foreach (var category in categories.List() ) { var safeLabel = category.XmlName.Replace( "&", "&&"); var getImage = ""; if (currentCategoryId == category.Id && guessCategoryResponse.CategoryId == category.Id) { // best guess selected image. getImage = @"getImage=""GetImageBoth"""; } else if (currentCategoryId == category.Id) { getImage = @"getImage=""GetImageSelected"""; } else if (guessCategoryResponse.CategoryId == category.Id) { getImage = @"getImage=""GetImageMaybe"""; } else { // no image } // best guess selected image. translationsXml.Append( $@"<button id =""myoddweb.classifier_manage_{category.Id}"" label=""{safeLabel}"" onAction=""OnSelectCategory"" {getImage}/>" ); } // if we have existing categories, add a separator // otherwise we don't need to if (categories.Count > 0 ) { translationsXml.Append(@"<menuSeparator id=""separator"" />"); } // show the email details // but only if we have selected one email. if (mailItem != null) { translationsXml.Append( $@"<button id =""{"myoddweb.classifier_details"}"" label=""{"Details ..."}"" onAction=""{"OnDetails"}"" />"); } // If the value is null, it means we have more than one mail item // we cannot set a magnet with multiple mails. // well, we could, but it is just to much to keep it simple to the user. if (mailItem != null) { translationsXml.Append( $@"<button id =""{"myoddweb.classifier_magnet"}"" label=""{"Magnet ..."}"" onAction=""{"OnMagnet"}"" />"); } translationsXml.Append( $@"<button id =""{"myoddweb.classifier_settings"}"" label=""{"Options ..."}"" onAction=""{"OnManageMore"}"" getImage=""GetImageOptions""/>"); translationsXml.Append(@"</menu>"); var menu = translationsXml.ToString(); return menu; }
/// <summary> /// Guess the posible new category id /// </summary> /// <param name="mailItem">the mail item itself.</param> /// <param name="categories">the categories tool we will use to re-categorise</param> /// <param name="currentCategoryId">The current value of the category</param> /// <returns>Categories.CategorizeResponse the new id or -1 if we don't know.</returns> protected async Task<Categories.CategorizeResponse> GuessPosibleCategory( _MailItem mailItem, int currentCategoryId, Categories categories ) { var guessCategoryResponse = new Categories.CategorizeResponse { CategoryId = 0, WasMagnetUsed = false }; if ( !_options.ReCheckIfCtrlKeyIsDown || (Control.ModifierKeys & Keys.Control) != Keys.Control) { // if we do not want to check options, then we don't want to do that. if ( !_options.ReCheckCategories ) { return guessCategoryResponse; } // if we currently have a category and we only want to check the // unknown categories, then we musn't check. if (currentCategoryId != -1 && _options.CheckIfUnownCategory) { return guessCategoryResponse; } } var currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { // guess where it could be going to now. if (mailItem != null) { guessCategoryResponse = await categories.CategorizeAsync(mailItem).ConfigureAwait(false); } } catch (Exception) { // @todo we need to log that there was an issue. guessCategoryResponse = new Categories.CategorizeResponse { CategoryId = 0, WasMagnetUsed = false }; } // reset the cursor. Cursor.Current = currentCursor; // add a debug message. Debug.WriteLine(guessCategoryResponse.CategoryId != currentCategoryId ? $"My new classifying guess for this message is : {guessCategoryResponse.CategoryId}" : $"My classifying guess for this message is category remains the same : {guessCategoryResponse.CategoryId}"); // return what we found return guessCategoryResponse; }
/// <summary> /// Action lors du clic sur le menuItem sélectionné du contextMenu du label "lbl_sendOffer". /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void lbl_MenuItemSelected_MouseLeftButtonUp(object sender, RoutedEventArgs e) { MenuItem clickedMenuItem = sender as MenuItem; string serviceName = clickedMenuItem.Header.ToString(); string temporaryTitle = InterimDatabase.GetTemporaryTitle(TemporaryID); string temporaryName = InterimDatabase.GetTemporaryName(TemporaryID); bool isCorrectServiceName = (!string.IsNullOrEmpty(serviceName)); bool isCorrectTemporaryTitle = (!string.IsNullOrEmpty(temporaryTitle)); bool isCorrectTemporaryName = (!string.IsNullOrEmpty(temporaryName)); // Vérifie le contenu des informations de l'intérimaire. if (isCorrectTemporaryTitle && isCorrectTemporaryName && isCorrectServiceName) { string messageBox = Results_Val.Default.ConfirmSendEmail + temporaryTitle + " " + temporaryName + Results_Val.Default.ForServiceOf + serviceName + Results_Val.Default.Ask; // Message de confirmation. DialogResult dialogResult = MessageBox.Show(messageBox, Results_Val.Default.TitleConfirmSendEmail, MessageBoxButtons.YesNo, MessageBoxIcon.Question); // Vérifie la réponse au message de confirmation. if (dialogResult == DialogResult.Yes) { string temporaryEmailAdress = InterimDatabase.GetTemporaryEmailAdress(TemporaryID); bool isCorrectEmailAdress = (!string.IsNullOrEmpty(temporaryEmailAdress)); // Vérifie le contenu de l'adresse email récupérée. if (isCorrectEmailAdress) { string dayName = InterimDatabase.DayName(); string dayNumber = InterimDatabase.DayNumber(); string month = InterimDatabase.MonthName(); string workTimetableStart = InterimDatabase.ReturnWorkTimetableStart(); string workTimetableEnd = InterimDatabase.ReturnWorkTimetableEnd(); List <string> offerInformations = new List <string>(); offerInformations.Add(temporaryEmailAdress); offerInformations.Add(temporaryTitle); offerInformations.Add(temporaryName); offerInformations.Add(dayName); offerInformations.Add(dayNumber); offerInformations.Add(month); offerInformations.Add(workTimetableStart); offerInformations.Add(workTimetableEnd); offerInformations.Add(serviceName); // Crée un message de proposition de mission. List <string> bodyMessageInformations = CreateBodyMessage(Results_Code.Default.TemplateOfferPath, offerInformations); _MailItem message = CreateMessage(bodyMessageInformations); // Vérifie la création du message, l'envoi de l'email de proposition de mission, l'enregistrement de la date d'envoi et du service de la proposition de mission. if (IsCreateMessage(message) && IsSentEmail(message) && InterimDatabase.SetSendDateAndService(TemporaryID, serviceName)) { // Affiche un message de réussite de l'envoi de l'email. MessageBox.Show(Results_Val.Default.EmailSent, Results_Val.Default.InformationTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); // Rafraichit l'interface des résultats. usc_results refreshResults = new usc_results(); Switcher.Switch(refreshResults); } else { // Affiche un message d'échec de l'envoi de l'email de proposition de mission. MessageBox.Show(Results_Val.Default.NullSendEmail, Results_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { // Affiche un message d'erreur. MessageBox.Show(Results_Val.Default.NullEmailAdress, Results_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { // Affiche un message d'erreur. MessageBox.Show(Results_Val.Default.NullInformations, Results_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private bool AllAttachmentsWereConvertedToPDF(int nExpectedCount, _MailItem sentMailItem) { Microsoft.Office.Interop.Outlook.Attachments attachmentsSent = sentMailItem.Attachments; if (attachmentsSent.Count != nExpectedCount) return false; for (int i = 1; i <= nExpectedCount; i++) { if (Path.GetExtension(attachmentsSent[i].FileName).ToLower() != ".pdf") return false; string sTempFile = Path.GetTempFileName(); attachmentsSent[i].SaveAsFile(sTempFile); bool bPassed = IsFilePDF(sTempFile); System.IO.File.Delete(sTempFile); if(!bPassed) return false; } return true; }