Exemplo n.º 1
0
        /// <summary>
        /// Email Manager that handels all the email funconality of the application
        /// </summary>
        /// <param name="fromEmailAdress">From where sould the email come from</param>
        public EmailManager(FromEmailAddress fromEmailAdress = FromEmailAddress.NoReply)
        {
            // Setting the smtp info
            smtpClient = new SmtpClient("smtp.zoho.eu", 587);

            // Seleting from wich email it sould come from
            switch (fromEmailAdress)
            {
            case FromEmailAddress.NoReply:
                smtpClient.Credentials = new NetworkCredential("*****@*****.**", "kevindt12");
                FromMailAddress        = new MailAddress("*****@*****.**", "Init Squad");
                break;

            case FromEmailAddress.Admins:
                throw new NotImplementedException();

            case FromEmailAddress.Kevin:
                throw new NotImplementedException();
            }

            // Setting Ssl
            smtpClient.EnableSsl = true;
        }
Exemplo n.º 2
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                MailMessage message = new MailMessage();
                SmtpClient  smtp    = new SmtpClient();
                if (string.IsNullOrEmpty(FromEmailAddress.Get(context)))
                {
                    message.From = new MailAddress(SMTP_Email.Get(context));
                }
                else
                {
                    message.From = new MailAddress(FromEmailAddress.Get(context));
                }


                foreach (string emailid in ToEmailAddress.Get(context).Trim().Split(';'))
                {
                    message.To.Add(new MailAddress(emailid));
                }

                if (!string.IsNullOrEmpty(CCEmailAddress.Get(context)))
                {
                    foreach (string emailid in CCEmailAddress.Get(context).Trim().Split(';'))
                    {
                        message.CC.Add(new MailAddress(emailid));
                    }
                }

                if (!string.IsNullOrEmpty(BccEmailAddress.Get(context)))
                {
                    foreach (string emailid in BccEmailAddress.Get(context).Trim().Split(';'))
                    {
                        message.Bcc.Add(new MailAddress(emailid));
                    }
                }


                message.Subject    = Subject.Get(context).Trim();
                message.IsBodyHtml = IsBodyHtml.Get(context); //to make message body as html
                message.Body       = Body.Get(context).Trim();

                Console.WriteLine("----------------------");


                if (MailAttachments.Get(context) != null)
                {
                    Console.WriteLine("Number of Attachments: " + MailAttachments.Get(context).Count.ToString());
                    foreach (string file in MailAttachments.Get(context))
                    {
                        message.Attachments.Add(new Attachment(file));
                    }
                }


                smtp.Port                  = Convert.ToInt32(SMTP_Port.Get(context));
                smtp.Host                  = SMTP_Server.Get(context).Trim();
                smtp.EnableSsl             = EnableSsl.Get(context);
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = new System.Net.NetworkCredential(SMTP_Email.Get(context), SMTP_password.Get(context));
                smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                smtp.Send(message);
                IsSuccess.Set(context, true);
                Result.Set(context, string.Empty);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.Message + "--" + e.Source);
                IsSuccess.Set(context, false);
                Result.Set(context, "Error: " + e.Message);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Email Manager that handels all the email funconality of the application
        /// </summary>
        /// <param name="smptServer">Custom smtp Server</param>
        /// <param name="port">Custom port</param>
        public EmailManager(string smptServer = "smtp.zoho.eu", int port = 587, bool enableSsl = true, FromEmailAddress fromEmailAdress = FromEmailAddress.NoReply)
        {
            // Setting the smtp server settings
            smtpClient = new SmtpClient(smptServer, port);

            // Seleting from wich email it sould come from
            switch (fromEmailAdress)
            {
            case FromEmailAddress.NoReply:
                smtpClient.Credentials = new NetworkCredential("*****@*****.**", "kevindt12");
                FromMailAddress        = new MailAddress("*****@*****.**", "Init Squad");
                break;

            case FromEmailAddress.Admins:
                throw new NotImplementedException();

            case FromEmailAddress.Kevin:
                throw new NotImplementedException();
            }

            // Setting the ssl settings
            smtpClient.EnableSsl = enableSsl;
        }