示例#1
0
        /*
         * public static ResultadoTransaccion EnviarHTmlEmail(string toValue, string subjectValue, string bodyValue)
         * {
         *  ResultadoTransaccion res = new ResultadoTransaccion();
         *  try
         *  {
         *      oApp = new Application();
         *      oNameSpace = oApp.GetNamespace("MAPI");
         *      oOutboxFolder = oNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
         *      _MailItem oMailItem = (_MailItem)oApp.CreateItem(OlItemType.olMailItem);
         *      oMailItem.To = toValue;
         *      oMailItem.Subject = subjectValue;
         *      if (oMailItem.HTMLBody.IndexOf("</BODY>") > -1)
         *          oMailItem.HTMLBody = oMailItem.HTMLBody.Replace("</BODY>", bodyValue);
         *
         *      oMailItem.SaveSentMessageFolder = oOutboxFolder;
         *      oMailItem.BodyFormat = OlBodyFormat.olFormatHTML;
         *
         *      oMailItem.Send();
         *
         *      res.Estado = Enums.EstadoTransaccion.Aceptada;
         *  }
         *  catch (Exception ex)
         *  {
         *      res.Descripcion = ex.Message;
         *      res.Estado = Enums.EstadoTransaccion.Rechazada;
         *
         *      Log.EscribirLog(ex.Message);
         *  }
         *
         *  return res;
         *
         * }
         */
        /// <summary>
        /// Metodo para el envio de Email desde el Modulo Calendario
        /// </summary>
        /// <param name="toValue">Email del receptor</param>
        /// <param name="subjectValue">Asunto del Email</param>
        /// <param name="bodyValue">Cuerpo del Email</param>
        public static ResultadoTransaccion EnviarEmail(string toValue, string subjectValue, string bodyValue)
        {
            ResultadoTransaccion res = new ResultadoTransaccion();

            try
            {
                oApp          = new Application();
                oNameSpace    = oApp.GetNamespace("MAPI");
                oOutboxFolder = oNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
                _MailItem oMailItem = (_MailItem)oApp.CreateItem(OlItemType.olMailItem);
                oMailItem.To      = toValue;
                oMailItem.Subject = subjectValue;
                oMailItem.Body    = bodyValue;
                oMailItem.SaveSentMessageFolder = oOutboxFolder;
                oMailItem.BodyFormat            = OlBodyFormat.olFormatRichText;

                oMailItem.Send();

                res.Estado = Enums.EstadoTransaccion.Aceptada;
            }
            catch (Exception ex)
            {
                res.Descripcion = ex.Message;
                res.Estado      = Enums.EstadoTransaccion.Rechazada;

                Log.EscribirLog(ex.Message);
            }

            return(res);
        }
示例#2
0
        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();
                }
            }
        }
        /// <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);
            }
        }
示例#4
0
        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");
        }
示例#5
0
        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");
        }
示例#6
0
 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);
 }