public static void Run()
        {
            // ExStart:EmbeddedObjects
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Email();
            string dstEmail = dataDir + "EmbeddedImage.msg";

            // Create an instance of the MailMessage class and Set the addresses and Set the content
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress("*****@*****.**");
            mail.To.Add("*****@*****.**");
            mail.Subject = "This is an email";

            // Create the plain text part It is viewable by those clients that don't support HTML
            AlternateView plainView = AlternateView.CreateAlternateViewFromString("This is my plain text content", null, "text/plain");

            /* Create the HTML part.To embed images, we need to use the prefix 'cid' in the img src value.
            The cid value will map to the Content-Id of a Linked resource. Thus <img src='cid:barcode'> will map to a LinkedResource with a ContentId of //'barcode'. */
            AlternateView htmlView = AlternateView.CreateAlternateViewFromString("Here is an embedded image.<img src=cid:barcode>", null, "text/html");

            // Create the LinkedResource (embedded image) and Add the LinkedResource to the appropriate view
            LinkedResource barcode = new LinkedResource(dataDir + "1.jpg", MediaTypeNames.Image.Jpeg)
            {
                ContentId = "barcode"
            };
            mail.LinkedResources.Add(barcode);
            mail.AlternateViews.Add(plainView);
            mail.AlternateViews.Add(htmlView);
            mail.Save(dataDir + "EmbeddedImage_out.msg", SaveOptions.DefaultMsgUnicode);
            // ExEnd:EmbeddedObjects
            Console.WriteLine(Environment.NewLine + "Message saved with embedded objects successfully at " + dstEmail);
        }
 public static Contact CreateContact(string name, Profile profile, LinkedResource linked_user)
 {
     Contact contact = new Contact();
     contact.name = name;
     contact.profile = profile;
     contact.linked_user = linked_user;
     return contact;
 }
Пример #3
0
        public static void SendEmail(string From, string Subject, string Body, string text, string To, string UserID, string Password, string SMTPPort, string Host, bool showAplired)
        {
            LinkedResource _logo = new LinkedResource(String.Format("{0}\\Logo-BiaPlus.png", _pathImages), MediaTypeNames.Image.Jpeg)
            {
                ContentId        = "Logo-BiaPlus",
                TransferEncoding = TransferEncoding.Base64
            };

            ContentType mimeType    = new System.Net.Mime.ContentType("text/html");
            HtmlString  _htmlString = new HtmlString(Body);

            AlternateView alternate = AlternateView.CreateAlternateViewFromString(_htmlString.ToHtmlString(), mimeType);

            alternate.LinkedResources.Add(_logo);
            if (showAplired)
            {
                LinkedResource _logoAplired = new LinkedResource(String.Format("{0}\\LogoAplired.png", _pathLogos), MediaTypeNames.Image.Jpeg)
                {
                    ContentId        = "LogoAplired",
                    TransferEncoding = TransferEncoding.Base64
                };
                alternate.LinkedResources.Add(_logoAplired);
            }


            System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            mail.To.Add(To);
            mail.From    = new MailAddress(From);
            mail.Subject = Subject;
            mail.Body    = text;
            mail.AlternateViews.Add(alternate);
            mail.IsBodyHtml = true;
            mail.Priority   = MailPriority.Normal;

            SmtpClient smtp = new SmtpClient();

            smtp.Host        = Host;
            smtp.Port        = Convert.ToInt16(SMTPPort);
            smtp.Credentials = new NetworkCredential(UserID, Password);
            smtp.EnableSsl   = false;
            try
            {
                smtp.Send(mail);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult ForgotPassword(string txtEmailAddress)
        {
            List <DCUsers> lstDCUsers = new List <DCUsers>();

            string strMessage = string.Empty;

            if (!string.IsNullOrEmpty(txtEmailAddress))
            {
                objBLUsers = new BLUsers();
                objDataOperationResponse = new DataOperationResponse();

                lstDCUsers = objBLUsers.ForgotPassword(txtEmailAddress);
                if (lstDCUsers.Count > 0)
                {
                    EmailAttributesModel objEmailAttributes = new EmailAttributesModel();
                    objEmailAttributes.Subject = "IRMA™ Onboarding Portal Password";
                    string imagePath = Server.MapPath(@"~/Images/mail.png");

                    var linkedResource = new LinkedResource(imagePath, MediaTypeNames.Image.Jpeg);
                    linkedResource.ContentId = "logoImage";
                    string body = "Hello " + lstDCUsers[0].FirstName + "," + " <br/><br/>" + "We heard that you lost your IRMA™ Onboarding Portal password. Sorry about that!"
                                  + "<br/><br/>" + "<b style='margin-left:30px;'>Your Password: </b>" + lstDCUsers[0].LastName + "<br/><br/>" + " Please contact the applicable support group for any questions or assistance:" + "<br/><br/>"
                                  + "<li style='margin-left:30px;'>Adaptive Risk System (ARS™) support team for questions related to the use of the IRMA™ Onboarding and/or Live applications.</li>"
                                  + "<li type='circle' style='margin:5px 60px'> <a href='mailto:" + AppConfig.SMTPEmailARS + "'>" + AppConfig.SMTPEmailARS + " </a></li> "
                                  + "<li type='circle' style='margin:5px 60px'> Mobile: " + AppConfig.SMTPPHNNO + "</li>"

                                  + "<li style='margin-left:30px;'>IRMA™ IT support team for any questions related to logon, password or other IT related issues.</li>"
                                  + "<li type='circle' style='margin:5px 60px'> <a href='mailto:" + AppConfig.SMTPEmailIRMA + "'> " + AppConfig.SMTPEmailIRMA + " </a></li> "

                                  + "<br/><br/>" + " We will respond to emails within 24 hours of receipt." + "<br/><br/>" + " Thank you and have a great day!" + "<br/><b> IRMA™ Support Team</b>" + "<br/> <img src='cid:logoImage' alt='Red dot' width='122' height='48' />";
                    var altView = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
                    altView.LinkedResources.Add(linkedResource);
                    objEmailAttributes.AlternateView = altView;
                    objEmailAttributes.MessageBody   = body;
                    objEmailAttributes.From          = AppConfig.SMTPEMAILFROM;
                    objEmailAttributes.To            = lstDCUsers[0].EmailAddress;
                    objEmailAttributes.CC            = "";
                    strMessage = SendMail(objEmailAttributes);
                    TempData["SuccessMessage"] = "Password has been sent to your mail";
                    return(RedirectToAction("Login"));
                }
                else
                {
                    TempData["ErrorMessage"] = "Email-id does not exist";
                    return(RedirectToAction("Login"));
                }
            }
            return(View());
        }
            public static string SendTestEMail()
            {
                try
                {
                    MailMessage mail = new MailMessage();

                    mail.From = new MailAddress(SendFrom);

                    mail.To.Clear();

                    string[] strMailTo = SendTo.Split(';');

                    foreach (string sMailTo in strMailTo)
                    {
                        mail.To.Add(sMailTo);
                    }

                    mail.Subject    = Subject;
                    mail.IsBodyHtml = true;
                    mail.Body       = GetTestMailBody();

                    AlternateView  av = AlternateView.CreateAlternateViewFromString(mail.Body, null, MediaTypeNames.Text.Html);
                    LinkedResource lr = new LinkedResource(LogoPath, MediaTypeNames.Image.Jpeg);
                    lr.ContentId = "imglogo";
                    av.LinkedResources.Add(lr);
                    mail.AlternateViews.Add(av);

                    SmtpServer.Port        = Convert.ToInt32(Port);
                    SmtpServer.Credentials = new System.Net.NetworkCredential(LoginId, Password);
                    SmtpServer.EnableSsl   = SSL;

                    string userState = "test message1";

                    if (Async)
                    {
                        SmtpServer.SendAsync(mail, userState);
                    }
                    else
                    {
                        SmtpServer.Send(mail);
                    }

                    return("Succeed");
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
Пример #6
0
        public void PostSendEmail(List <string> userNames, string subject, string body)
        {
            var smtpClient = new SmtpClient
            {
                Host = SMTP,
                Port = 587,
                UseDefaultCredentials = false,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                Credentials           = new NetworkCredential(MailAccount, MailPassword),
                EnableSsl             = true
            };

            #region Configurar Mail

            var mail = new MailMessage
            {
                From = new MailAddress(MailAccount, MailDisplayName)
            };

            foreach (var item in userNames)
            {
                mail.To.Add(new MailAddress(item.ToString()));
            }

            #endregion
            #region ImageMail
            var rootFolder = AppDomain.CurrentDomain.BaseDirectory;
            var logopath   = Path.Combine(rootFolder, "MailImages/logo.jpg");
            var logo       = new LinkedResource(logopath, MediaTypeNames.Image.Jpeg);
            logo.ContentId = "logo";
            var html = AlternateView.CreateAlternateViewFromString(body, null, MediaTypeNames.Text.Html);
            html.LinkedResources.Add(logo);
            #endregion

            #region Set values to mail

            mail.Subject    = subject;
            mail.IsBodyHtml = true;
            mail.Body       = body;
            mail.AlternateViews.Add(html);

            #endregion Set values to mail

            smtpClient.SendAsync(mail, null);
            smtpClient.SendCompleted += (sender, args) => {
                smtpClient.Dispose();
                mail.Dispose();
            };
        }
Пример #7
0
        void SendEMail()
        {
            try
            {
                DataSet ds = new DataSet();

                if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + System.IO.Path.DirectorySeparatorChar + "HelpMeprofilesettings.xml"))
                {
                    ds.ReadXml(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + System.IO.Path.DirectorySeparatorChar + "HelpMeprofilesettings.xml");
                }

                MailMessage mail = new MailMessage();

                mail.From = new MailAddress(ds.Tables[0].Rows[0]["sender"].ToString());

                mail.To.Clear();

                string[] strMailTo = ds.Tables[0].Rows[0]["receiver"].ToString().Split(';');

                foreach (string sMailTo in strMailTo)
                    mail.To.Add(sMailTo);

                mail.Subject = Subject;
                mail.IsBodyHtml = true;
                mail.Body = GetMailBody();

                AlternateView av = AlternateView.CreateAlternateViewFromString(mail.Body, null, MediaTypeNames.Text.Html);
                LinkedResource lr = new LinkedResource(LogoPath, MediaTypeNames.Image.Jpeg);
                lr.ContentId = "imglogo";
                av.LinkedResources.Add(lr);
                mail.AlternateViews.Add(av);

                SmtpServer.Port = Convert.ToInt32(ds.Tables[0].Rows[0]["port"].ToString());
                SmtpServer.Credentials = new System.Net.NetworkCredential(ds.Tables[0].Rows[0]["Id"].ToString(), new HelpMeDatabaseConfiguration.Configurations.DatabaseSecurity().DecryptString(ds.Tables[0].Rows[0]["pass"].ToString()));
                SmtpServer.EnableSsl = SSL;

                string userState = "test message1";

                if (Convert.ToBoolean(ds.Tables[0].Rows[0]["async"].ToString()) == true)
                {
                    SmtpServer.SendAsync(mail, userState);
                }
                else
                {
                    SmtpServer.Send(mail);
                }
            }
            catch { }
        }
Пример #8
0
        public bool sndMailHeader(string strTo, string strHTMLBody, string strSubject)
        {
            MailMessage objMail = new MailMessage();
            SmtpClient  objsmtp = new SmtpClient();
            bool        isSent;

            try
            {
                //string pathImg = HttpContext.Current.Server.MapPath("~/images/cabecera.gif");
                string server      = ConfigurationSettings.AppSettings["mailServer"].ToString();
                string mailAccount = ConfigurationSettings.AppSettings["mailAccount"].ToString();
                objMail.From    = new MailAddress(mailAccount);
                objsmtp.Host    = server;
                objMail.Subject = strSubject;
                if (strTo.Contains("@mdlz.com"))
                {
                    objMail.To.Add(strTo);
                }
                else
                {
                    objMail.To.Add(strTo + "@mdlz.com");
                }
                //objMail.To.Add(strTo);
                //if (this.strCc != string.Empty)
                objMail.CC.Add("*****@*****.**");
                //if (this.strBcc != string.Empty)
                //    msgMail.Bcc.Add(this.strBcc);
                LinkedResource img = new LinkedResource(@"D:\SisContratos\app\images\cabecera.jpg", MediaTypeNames.Image.Jpeg);
                AlternateView  av1 = AlternateView.CreateAlternateViewFromString(strHTMLBody, null, MediaTypeNames.Text.Html);
                av1.LinkedResources.Add(img);
                img.ContentId = "imagen";
                objMail.AlternateViews.Add(av1);
                objMail.IsBodyHtml = true;
                objMail.Body       = strHTMLBody;
                objsmtp.Send(objMail);
                isSent = true;
            }
            catch (Exception ex)
            {
                string err = ex.Message;
                isSent = false;
            }
            finally
            {
                objMail.Dispose();
            }

            return(isSent);
        }
Пример #9
0
        private AlternateView LinkedFiles(string bodyHtml, Dictionary <string, string> files)
        {
            var view = AlternateView.CreateAlternateViewFromString(bodyHtml, null, MediaTypeNames.Text.Html);

            foreach (var x in files)
            {
                var linked = new LinkedResource(x.Value, MediaTypeNames.Application.Octet)
                {
                    ContentId = x.Key
                };
                view.LinkedResources.Add(linked);
            }

            return(view);
        }
Пример #10
0
        static public AlternateView getEmbeddedImage(string filePath, string content)

        {
            LinkedResource res = new LinkedResource(filePath);

            res.ContentId = content;
            string        htmlBody      = @"<img src='cid:" + res.ContentId + @"'/>";
            AlternateView alternateView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);

            alternateView.LinkedResources.Add(res);



            return(alternateView);
        }
Пример #11
0
        public void ShouldRetrieveLinkedResource()
        {
            ISmtpClient smtpClient  = new EmailClient();
            var         imageSource = $@"{AppDomain.CurrentDomain.SetupInformation.ApplicationBase}Utils\Images\govuklogo.png";
            var         imageId     = "someid";

            byte[] expectedBytes = StreamExtensions.GetBytesFromFile(imageSource);

            LinkedResource resource = smtpClient.GetLinkedResource(imageSource, imageId);

            byte[] actualBytes = resource.ContentStream.ReadAllBytes();

            Assert.AreEqual(imageId, resource.ContentId);
            Assert.AreEqual(expectedBytes, actualBytes);
        }
Пример #12
0
        private static AlternateView getEmbeddedImage(string body, List <string> filepath, List <string> cid)
        {
            string         htmlBody = body;
            LinkedResource inline;
            AlternateView  alternateView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);

            for (int i = 0; i < filepath.Count; i++)
            {
                inline           = new LinkedResource(HttpContext.Current.Server.MapPath(filepath[i]));
                inline.ContentId = cid[i];
                alternateView.LinkedResources.Add(inline);
            }

            return(alternateView);
        }
        private AlternateView getEmbeddedImage(String filePath, string fname, Employee loggedInEmployee)
        {
            LinkedResource inline = new LinkedResource(filePath);

            inline.ContentId = Guid.NewGuid().ToString();
            //string htmlBody = @"<img src='cid:" + inline.ContentId + @"'/>";
            string htmlBody = "<html><body>Congratulations " + fname + "!" + "<br/><br/>"
                              + "You have just been awarded a consultation card by " + loggedInEmployee.FirstName + " " + loggedInEmployee.LastName + ".<br /><br />" + @"<img src='cid:" + inline.ContentId + @"'/>"
                              + "<br /><br />"
                              + "This puts you one step closer to earning an entry into the monthly custom swag drawing.<br /><br />Keep up the great work!</body></html>";
            AlternateView alternateView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);

            alternateView.LinkedResources.Add(inline);
            return(alternateView);
        }
Пример #14
0
        private AlternateView CreateHtmlMessage(string message, string logoPath)
        {
            var inline = new LinkedResource(logoPath, "image/png");

            inline.ContentId = "companyLogo";

            var alternateView = AlternateView.CreateAlternateViewFromString(
                message,
                Encoding.UTF8,
                MediaTypeNames.Text.Html);

            alternateView.LinkedResources.Add(inline);

            return(alternateView);
        }
Пример #15
0
        public static string SendEMail(Student s, Bitmap image)
        {
            var reciever = new MailAddress(s.EMail);

            string photoPath, guidStr;

            SaveBitmap(image, s, out photoPath, out guidStr);

            var mail = new MailMessage(_senderAddress, reciever)
            {
                HeadersEncoding = Encoding.UTF8,
                SubjectEncoding = Encoding.UTF8,
                BodyEncoding    = Encoding.UTF8,
                Subject         = Config.MailSubject,
            };

            var pic = new Attachment(photoPath, new ContentType("image/jpeg"))
            {
                Name = Config.MailPhotoName,
                ContentDisposition = { Inline = true }
            };


            var plainTextView = AlternateView.CreateAlternateViewFromString(Config.MailPlainContent, Encoding.UTF8,
                                                                            MediaTypeNames.Text.Plain);
            var htmlView = AlternateView.CreateAlternateViewFromString(Config.MailHtmlContent, Encoding.UTF8,
                                                                       MediaTypeNames.Text.Html);

            var inline = new LinkedResource(photoPath, MediaTypeNames.Image.Jpeg)
            {
                ContentId = "photo"
            };

            htmlView.LinkedResources.Add(inline);

            mail.AlternateViews.Add(plainTextView);
            mail.AlternateViews.Add(htmlView);

            mail.Attachments.Add(pic);

#if DEBUG
            _smtpClient.Send(mail);
#else
            var task = _smtpClient.SendMailAsync(mail);
            task.GetAwaiter().OnCompleted(() => MessageBox.Show(@"Message sent."));
#endif
            return(guidStr);
        }
Пример #16
0
        public static void SendEmail(MailosaurClient client, string server, string sendToAddress = null)
        {
            var host = Environment.GetEnvironmentVariable("MAILOSAUR_SMTP_HOST") ?? "mailosaur.io";
            var port = Environment.GetEnvironmentVariable("MAILOSAUR_SMTP_PORT") ?? "25";

            var message = new MailMessage();

            var randomString = RandomString();

            message.Subject = randomString + " subject";

            message.From = new MailAddress($"{randomString} {randomString} <{client.Servers.GenerateEmailAddress(server)}>");

            var randomToAddress = sendToAddress ?? client.Servers.GenerateEmailAddress(server);

            message.To.Add($"{randomString} {randomString} <{randomToAddress}>");

            // Text body
            message.Body         = s_Text.Replace("REPLACED_DURING_TEST", randomString);
            message.IsBodyHtml   = false;
            message.BodyEncoding = Encoding.UTF8;

            // Html body
            var htmlString = s_Html.Replace("REPLACED_DURING_TEST", randomString);
            var htmlView   = AlternateView.CreateAlternateViewFromString(htmlString,
                                                                         new ContentType(MediaTypeNames.Text.Html));

            htmlView.TransferEncoding = TransferEncoding.Base64;
            message.AlternateViews.Add(htmlView);

            var image = new LinkedResource(Path.Combine("Resources", "cat.png"));

            image.ContentId   = "ii_1435fadb31d523f6";
            image.ContentType = new ContentType("image/png");
            htmlView.LinkedResources.Add(image);

            var attachment = new System.Net.Mail.Attachment(Path.Combine("Resources", "dog.png"));

            attachment.ContentType = new ContentType("image/png");
            message.Attachments.Add(attachment);

            var smtp = new SmtpClient();

            smtp.Host = host;
            smtp.Port = int.Parse(port);

            smtp.Send(message);
        }
Пример #17
0
        public static void PreProcessHtmlMail(MailMessage mail)
        {
            // If the mail is not in HTML
            if (mail.Body.IndexOf("<html>") == -1)
            {
                return;
            }

            // Set HTML Body
            mail.IsBodyHtml = true;

            // Embedd images as Base64
            ArrayList    linkedResources = new ArrayList();
            XmlDocument  xml             = new XmlDocument();
            StringReader s = new StringReader(mail.Body);

            xml.Load(s);
            int imageCount = 0;

            foreach (XmlNode node in xml.SelectNodes("//img"))
            {
                imageCount++;
                XmlAttribute attr = node.Attributes["src"];
                String       file = Config.Paths.Application + attr.Value.Replace("/", "\\");

                // Add resource
                LinkedResource resource = new LinkedResource(file);
                resource.ContentId        = "image" + imageCount.ToString();
                resource.TransferEncoding = TransferEncoding.Base64;
                linkedResources.Add(resource);

                // Change Source
                attr.Value = "cid:" + resource.ContentId;
            }

            // Update Body
            mail.Body = xml.InnerXml;

            // Add HTML view plus all linked resources
            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(mail.Body, null, "text/html");

            foreach (LinkedResource resource in linkedResources)
            {
                htmlView.LinkedResources.Add(resource);
            }

            mail.AlternateViews.Add(htmlView);
        }
Пример #18
0
        public async Task SendResetPasswordEmail(string receiverEmail, string name, string resetLink)
        {
            var template = Template.Parse(_emailTemplate);
            var body     = await template.RenderAsync(new { Name = name, Link = resetLink });

            var email = new MailMessage(new MailAddress("*****@*****.**", "SMP"), new MailAddress(receiverEmail))
            {
                Subject    = "SMP - Password Reset",
                IsBodyHtml = true
            };

            var view  = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
            var bgTop = new LinkedResource("Resources/Email/bg_top.jpg")
            {
                ContentId = "bg_top"
            };
            var bgBottom = new LinkedResource("Resources/Email/bg_bottom.jpg")
            {
                ContentId = "bg_bottom"
            };
            var smpLogo = new LinkedResource("Resources/Email/smp-logo.png")
            {
                ContentId = "smplogo"
            };
            var instagram = new LinkedResource("Resources/Email/instagram2x.png")
            {
                ContentId = "instagram"
            };
            var linkedin = new LinkedResource("Resources/Email/linkedin2x.png")
            {
                ContentId = "linkedin"
            };
            var twitter = new LinkedResource("Resources/Email/twitter2x.png")
            {
                ContentId = "twitter"
            };

            view.LinkedResources.Add(bgTop);
            view.LinkedResources.Add(bgBottom);
            view.LinkedResources.Add(smpLogo);
            view.LinkedResources.Add(instagram);
            view.LinkedResources.Add(linkedin);
            view.LinkedResources.Add(twitter);

            email.AlternateViews.Add(view);

            await _smtpClient.SendMailAsync(email);
        }
Пример #19
0
    static void Main(string[] args)
    {
        /////////////////////////////////////////////////////////////////////
        // 创建邮件对象。
        //

        Console.WriteLine("创建邮件对象。");

        MailMessage mail = new MailMessage();
        mail.To.Add("*****@*****.**");
        mail.From = new MailAddress("*****@*****.**");
        mail.Subject = "Test email of All-In-One Code Framework - CSSMTPSendEmail";
        mail.Body = "Welcome to <a href='http://cfx.codeplex.com'>All-In-One Code Framework</a>!";
        mail.IsBodyHtml = true;

        // 附件
        Console.WriteLine("添加附件");
        string attachedFile = "<attached file path>";
        mail.Attachments.Add(new Attachment(attachedFile));

        // 在消息体中嵌入图片。
        Console.WriteLine("嵌入图片");
        mail.Body += "<br/><img alt=\"\" src=\"cid:image1\">";

        string imgFile = "<image file path>";
        AlternateView htmlView = AlternateView.CreateAlternateViewFromString(
            mail.Body, null, "text/html");
        LinkedResource imgLink = new LinkedResource(imgFile, "image/jpg");
        imgLink.ContentId = "image1";
        imgLink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
        htmlView.LinkedResources.Add(imgLink);
        mail.AlternateViews.Add(htmlView);

        /////////////////////////////////////////////////////////////////////
        // 配置SMTP客户端并发送邮件.
        //

        // 配置SMTP客户端
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.live.com";
        smtp.Credentials = new NetworkCredential(
            "*****@*****.**", "mypassword");
        smtp.EnableSsl = true;

        // 发送邮件
        Console.WriteLine("发送邮件...");
        smtp.Send(mail);
    }
        public void sendMail(IView_EnviarEmail view)
        {
            string destino         = view.destino;
            string usernameDestino = destino.Split('(', ')')[1];

            AutorModel autorDestino   = listaAutores.Find(x => x.usernamePK == usernameDestino);
            string     nombreCompleto = autorDestino.nombre + " " + autorDestino.apellido1 + " " + autorDestino.apellido2;
            string     emailAddress   = autorDestino.email;

            string asunto      = "[TheCoffeePlace] " + view.asunto;
            string mensajeHtml = "<h3>Estimado " + nombreCompleto + ",</h3>" +
                                 "<p><i>Has recibido un mensaje de The Coffee Place: </i><br/><br/>" + view.mensaje +
                                 "<br/><br/><i> Para responder, por favor hacerlo desde nuestro sitio web. </i><br/><br/></p>";

            MailAddress fromAddress = new MailAddress("*****@*****.**", "The Coffee Place");
            MailAddress toAddress   = new MailAddress(emailAddress, nombreCompleto);

            const string fromPassword = "******";

            var smtp = new SmtpClient {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
            };


            LinkedResource resource = new LinkedResource(HttpContext.Current.Server.MapPath("~/Imagenes/Sitio/logoTCP.png"), "image/png");

            resource.ContentId = Guid.NewGuid().ToString();
            string htmlImage = @"<img src='cid:" + resource.ContentId + @"'/>";

            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(mensajeHtml + htmlImage, Encoding.UTF8, MediaTypeNames.Text.Html);

            htmlView.LinkedResources.Add(resource);

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = asunto,
                IsBodyHtml = true,
            })
            {
                message.AlternateViews.Add(htmlView);
                smtp.Send(message);
            }
        }
Пример #21
0
        private AlternateView Mail_Body(string filename, string paymentid)
        {
            string         path = Server.MapPath("~/QRcode/" + filename);
            LinkedResource Img  = new LinkedResource(path, MediaTypeNames.Image.Jpeg);

            Img.ContentId = "MyImage";
            string        str = @"  
            <table>  
                <tr>  
                    <td> '" + "Your Receipt ID:" + paymentid + @"'  
                    </td>  
<tr>
<td>
<hr/>
</td>
</tr>
<tr>
<td>
Please keep you receipt to express printing shop to bring you document.<br/>
</td>
</tr>
                </tr>  
                <tr>  
                    <td>  
                      <img src=cid:MyImage  id='img' alt='' width='100px' height='100px'/>   
                    </td>  
                    <td>
                </tr><br/>


<tr>
<td>
Best Regards,
</td>
</tr>
<tr>
<td>
Express Printing System Admin 
</td>
</tr>
</table>  
            ";
            AlternateView AV  =
                AlternateView.CreateAlternateViewFromString(str, null, MediaTypeNames.Text.Html);

            AV.LinkedResources.Add(Img);
            return(AV);
        }
Пример #22
0
 private static AlternateView getEmbeddedImage(String filePath)
 {
     try
     {
         LinkedResource inline = new LinkedResource(filePath);
         inline.ContentId = Guid.NewGuid().ToString();
         string        htmlBody      = @"<img src='cid:" + inline.ContentId + @"'/>";
         AlternateView alternateView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
         alternateView.LinkedResources.Add(inline);
         return(alternateView);
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #23
0
        public static LinkedResource[] GetTemplateLinkedResources(System.Web.UI.Page parent)
        {
            LinkedResource[] resources = new LinkedResource[5];
            //resources[0] = new LinkedResource(parent.Server.MapPath("~/web/themes/images/logo.jpg"));
            //resources[0].ContentId = "logo";
            //resources[1] = new LinkedResource(parent.Server.MapPath("~/web/themes/images/TabBGactive.jpg"));
            //resources[1].ContentId = "activebg";
            //resources[2] = new LinkedResource(parent.Server.MapPath("~/web/themes/images/TabBGhover.jpg"));
            //resources[2].ContentId = "hoverbg";
            //resources[3] = new LinkedResource(parent.Server.MapPath("~/web/themes/images/TabBG.jpg"));
            //resources[3].ContentId = "bg";
            //resources[4] = new LinkedResource(parent.Server.MapPath("~/web/themes/images/contentCorner.jpg"));
            //resources[4].ContentId = "cornerbg";

            return(resources);
        }
Пример #24
0
        AddLinkedResourceForFullSizeImage
        (
            Byte [] abtFullSizeImage,
            AlternateView oHtmlView
        )
        {
            Debug.Assert(abtFullSizeImage != null);
            Debug.Assert(oHtmlView != null);
            AssertValid();

            LinkedResource oFullSizeImageResource = new LinkedResource(
                new MemoryStream(abtFullSizeImage), PngContentType);

            oFullSizeImageResource.ContentId = FullSizeImageContentId;
            oHtmlView.LinkedResources.Add(oFullSizeImageResource);
        }
Пример #25
0
        /// <summary>
        /// Provides the body of a nicely formatted follow-up email
        /// </summary>
        /// <param name="name">The name of the patron requesting the email</param>
        /// <param name="pub">The Publication instance to be advertised</param>
        /// <param name="cover">The cover image of the publications</param>
        /// <returns>HTML body of email</returns>
        static string getMessageBody(String name, Publication pub, LinkedResource cover)
        {
            string sTemplate = @"
<p>{{name}},</p>
<p><a href='{{link}}'>Click here</a> to borrow {{pubname}}.</p>
<div><a href='{{link}}'><img src='cid:{{coverURI}}' /></a></div>
<p><a href='{{link2}}'>More information on Bucknell eBooks</a></p>";
            Dictionary <string, string> data = new Dictionary <string, string>();

            data["name"]     = name;
            data["pubname"]  = pub.Title;
            data["link"]     = "https://bucknell.worldcat.org/oclc/" + pub.OCLCNumber;
            data["link2"]    = "http://researchbysubject.bucknell.edu/ebooks";
            data["coverURI"] = cover.ContentId;
            return(Nustache.Core.Render.StringToString(sTemplate, data));
        }
Пример #26
0
        private AlternateView GetEmbeddedImage(String filePath, string template, string token)
        {
            LinkedResource res = new LinkedResource(filePath);

            res.ContentType = new ContentType()
            {
                MediaType = "image/png",
                Name      = "logo_transparent.png"
            };
            res.ContentId = Guid.NewGuid().ToString();
            string        htmlBody      = string.Format(template, res.ContentId, token);
            AlternateView alternateView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);

            alternateView.LinkedResources.Add(res);
            return(alternateView);
        }
Пример #27
0
        /// <summary>
        /// Builds a html alternateview object applying the image attachements.
        /// </summary>
        /// <param name="htmlBody">the body with variables applied</param>
        /// <param name="imageAttachments">the image attachments</param>
        /// <returns>the alternateview of the html email passed in with added images.</returns>
        private static AlternateView BuildHtmlView(String htmlBody, Dictionary <String, ImageAttachment> imageAttachments)
        {
            AlternateView htmlView;

            htmlView = AlternateView.CreateAlternateViewFromString(htmlBody, null, "text/html");

            foreach (String key in imageAttachments.Keys)
            {
                LinkedResource imageLink = new LinkedResource(key, imageAttachments[key].MimeType);
                imageLink.ContentId        = imageAttachments[key].ContentId;
                imageLink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
                htmlView.LinkedResources.Add(imageLink);
            }

            return(htmlView);
        }
Пример #28
0
        private static LinkedResource GetDefaultLogoFromEmbeddedResource()
        {
            try
            {
                var defaultLogo  = new Bitmap(DefaultImages.DefaultLogo);
                var memoryStream = new MemoryStream();
                defaultLogo.Save(memoryStream, ImageFormat.Png);
                memoryStream.Seek(0, SeekOrigin.Begin);

                return(new LinkedResource(memoryStream, "image/png"));
            }
            catch (Exception)
            {
                return(LinkedResource.CreateLinkedResourceFromString("Logo"));
            }
        }
Пример #29
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            long trick = DateTime.Now.Ticks;

            try
            {
                using (System.Net.Mail.SmtpClient client = new SmtpClient("smtp.qq.com"))
                {
                    client.UseDefaultCredentials = false;
                    client.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "lhw521zxh");
                    client.DeliveryMethod        = SmtpDeliveryMethod.Network;

                    MailAddress addressFrom = new MailAddress("*****@*****.**", "多媒体课件编辑器-意见反馈");
                    MailAddress addressTo   = new MailAddress("*****@*****.**", "多媒体课件编辑器-意见反馈");

                    using (System.Net.Mail.MailMessage message = new MailMessage(addressFrom, addressTo))
                    {
                        message.Sender       = new MailAddress("*****@*****.**");
                        message.BodyEncoding = System.Text.Encoding.UTF8;
                        message.IsBodyHtml   = true;
                        message.Subject      = DateTime.Now + "---" + "意见反馈";


                        SaveFrameworkElementToImage(this, trick + ".bmp");
                        Attachment     attcahment = new Attachment(trick + ".bmp");
                        LinkedResource linked     = new LinkedResource(trick + ".bmp", "image/gif");
                        linked.ContentId = "weblogo";
                        string        htmlBodyContent = GetHtmlContent("weblogo");
                        AlternateView htmlBody        = AlternateView.CreateAlternateViewFromString(htmlBodyContent, null, "text/html");

                        htmlBody.LinkedResources.Add(linked);
                        message.AlternateViews.Add(htmlBody);
                        client.Send(message);
                        MessageBox.Show("提交成功,非常感谢您的意见!");
                        attcahment.Dispose();
                        linked.Dispose();
                        htmlBody.Dispose();
                    }
                }
                File.Delete(trick + ".bmp");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("提交失败!");
            }
        }
Пример #30
0
        public static bool SendEmail(string _to, string _subject, string _body, List <string> _anexos, string _cc)
        {
            try
            {
                AlternateView  view     = AlternateView.CreateAlternateViewFromString(_body, null, MediaTypeNames.Text.Html);
                LinkedResource resource = new LinkedResource(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\logot.png"));

                resource.ContentId = "Imagem1";
                view.LinkedResources.Add(resource);

                MailMessage mailMessage = new MailMessage("*****@*****.**", _to, _subject, _body)
                {
                    IsBodyHtml = true
                };


                if (_cc != null)
                {
                    MailAddress cc = new MailAddress(_cc);
                    mailMessage.CC.Add(cc);
                }


                if (_anexos != null)
                {
                    foreach (string item in _anexos)
                    {
                        mailMessage.Attachments.Add(new Attachment(item));
                    }
                }

                mailMessage.AlternateViews.Add(view);
                mailMessage.Priority = MailPriority.Normal;

                SmtpClient client = new SmtpClient("pgjsrv129", 25);
                client.UseDefaultCredentials = true;

                client.Send(mailMessage);

                return(true);
            }
            catch (Exception e)
            {
                e.Message.ToString();
                return(false);
            }
        }
Пример #31
0
    public void composeMessage(string from, string to, string Subject, string message, string imagePath = "")
    {
        string      ImagePath = imagePath;
        MailMessage MyMessage = new MailMessage(from, to);

        MyMessage.Subject      = Subject;
        MyMessage.BodyEncoding = UTF8Encoding.UTF8;
        MyMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
        MyMessage.IsBodyHtml = true;

        if (ImagePath.Length > 0)
        {
            // compose with image from path
            var inlineLogo = new LinkedResource(ImagePath, "image/png");
            inlineLogo.ContentId = Guid.NewGuid().ToString();

            string body = string.Format(@"
            <h2>Here your chart info:</h2>
            <p>{0}</p>
            <p></p>
            <img src=""cid:{1}"" />
            <p></p>
            <p></p>
            <p>Nestor Colt Informatic Trading Solutions 2018</p>
            ", message, inlineLogo.ContentId);

            var view = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
            view.LinkedResources.Add(inlineLogo);
            MyMessage.AlternateViews.Add(view);
        }
        else
        {
            string body = string.Format(@"
            <h2>Here your chart info:</h2>
            <p>{0}</p>
            <p></p>
            <p></p>
            <p>Nestor Colt Informatic Trading Solutions 2018</p>
            ", message);
            //
            MyMessage.Body = body;
        }

        // Send anyway
        client.Send(MyMessage);
        Console.WriteLine("Email Sent");
    }
Пример #32
0
        public void NotificarMiembro(string UsuarioActual, string titulo)
        {
            //Primero ocupo encontrar el correo del miembro
            connection();
            string correoDestinatario = "";

            con.Open();
            SqlCommand cmd = new SqlCommand("ObtenerCorreo", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@NombreUsuario", SqlDbType.VarChar).Value = UsuarioActual;
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                correoDestinatario = reader[0].ToString();
            }

            reader.Close();
            con.Close();



            MailMessage mm = new MailMessage();

            mm.To.Add(correoDestinatario);
            mm.Subject = "Notificacion de articulo ";
            AlternateView imgview = AlternateView.CreateAlternateViewFromString("Se ha empezado el proceso de revision en el articulo con el titulo:" + titulo
                                                                                + "<br/><br/><br/><br/><img src=cid:imgpath height=200 width=400>", null, "text/html");
            var            pathName = "~/Imagenes/shieldship.jpg";
            var            fileName = Server.MapPath(pathName);
            LinkedResource lr       = new LinkedResource(fileName, MediaTypeNames.Image.Jpeg);

            lr.ContentId = "imgpath";
            imgview.LinkedResources.Add(lr);
            mm.AlternateViews.Add(imgview);
            mm.Body       = lr.ContentId;
            mm.IsBodyHtml = false;
            mm.From       = new MailAddress("*****@*****.**");
            SmtpClient smtp = new SmtpClient("smtp.gmail.com");

            smtp.Port = 587;
            smtp.UseDefaultCredentials = true;
            smtp.EnableSsl             = true;
            smtp.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "BASESdatos176");
            smtp.Send(mm);
        }
Пример #33
0
        public static void EnviarEmail(string destinatario, string assunto, string mensagem,
                                       string emailRemetente, string nomeRemetente, SmtpClient sc, List <KeyValuePair <string, string> > linkedResources = null)
        {
            if (sc == null)
            {
                throw new Exception("Nenhum servidor de E-mail Foi encontrado. Redefina as configurações de e-mail.");
            }

            var m = new MailMessage
            {
                Body    = mensagem,
                Subject = assunto,
                From    =
                    new MailAddress(emailRemetente,
                                    string.IsNullOrEmpty(nomeRemetente) ? emailRemetente : nomeRemetente)
            };

            if (linkedResources != null && linkedResources.Any())
            {
                var htmlView = AlternateView.CreateAlternateViewFromString(mensagem, System.Text.Encoding.UTF8, "text/html");

                foreach (var linkedResource in linkedResources)
                {
                    var theEmailImage = new LinkedResource(linkedResource.Value)
                    {
                        ContentId = linkedResource.Key
                    };

                    //Add the Image to the Alternate view
                    htmlView.LinkedResources.Add(theEmailImage);
                }


                m.AlternateViews.Add(htmlView);
            }


            var emails = destinatario.Split(',');

            foreach (var email in emails)
            {
                m.To.Add(new MailAddress(email.Trim()));
            }

            m.IsBodyHtml = true;
            sc.Send(m);
        }
Пример #34
0
    public bool sendEmail(string _conName, string mappath, string _conEmail, string _conReason, string _conMessage)
    {
        MailMessage objMail = new MailMessage(_conEmail, _conEmail, _conReason, _conMessage);
        NetworkCredential objNC = new NetworkCredential("*****@*****.**", "_timmins");
        SmtpClient objSMTP = new SmtpClient("smtp.gmail.com", 587); // smptp server for gmail

        LinkedResource backgroundimg = new LinkedResource(mappath);
        backgroundimg.ContentId = "background";
        // done HTML formatting in the next line to display my logo
        AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html><body><img src=cid:background/><br>" + _conMessage +"</body></html>", null, MediaTypeNames.Text.Html);

        using (objSMTP)
        {

            av1.LinkedResources.Add(backgroundimg);
            objMail.AlternateViews.Add(av1);
            objMail.IsBodyHtml = true; // allows use of html in body
            objSMTP.EnableSsl = true; // enable ssl, required for gmail
            objSMTP.Credentials = objNC;
            objSMTP.Send(objMail);
            return true;
        }
    }
Пример #35
0
 public LinkedResourceCollectionTest()
 {
     lrc = AlternateView.CreateAlternateViewFromString("test", new ContentType("text/plain")).LinkedResources;
     lr = LinkedResource.CreateLinkedResourceFromString("test", new ContentType("text/plain"));
 }
 public static Order createOrder(double price, int total_volume, int daily_volume, DateTime start_date, DateTime end_date, 
     LinkedResource linked_zone, LinkedResource linked_campaign)
 {
     Order order = new Order();
     order.gross_purchase_price = price;
     order.net_purchase_price = price;
     order.maximum_bid_price = price;
     order.total_volume = total_volume;
     order.daily_volume = daily_volume;
     order.start_date = start_date;
     order.end_date = end_date != default(DateTime) ? end_date : end_date;
     order.linked_zone = linked_zone;
     order.linked_campaign = linked_campaign;
     return order;
 }
Пример #37
0
 private AlternateView getEmbeddedImage(String filePath)
 {
     LinkedResource inline = new LinkedResource(filePath);
     inline.ContentId = Guid.NewGuid().ToString();
     string htmlBody = "Geachte Heer/Mevrouw " + userName + "<br>Opname van: " + amount + "€<br>Rekeningnummer: " + rekeningNr + "<br>" + "<br>" + "<br>" + "<br>" + "Bedankt voor uw transactie" + "<br>" + "<br>" + "Met vriendelijke groet," + "<br>" + "Salty Solutions Bank" + "<br>" + @"<img src='cid:" + inline.ContentId + @"'/>";
     AlternateView alternateView = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);
     alternateView.LinkedResources.Add(inline);
     return alternateView;
 }
Пример #38
0
 public static Ad createAd(string name, int width, int height, string format, Creative creative, 
     LinkedResource linked_user, LinkedResource linked_contact, LinkedResource linked_targeting_plan)
 {
     Ad ad = new Ad();
     ad.name = name;
     ad.width = width;
     ad.height = height;
     ad.format = format;
     ad.creative = creative;
     ad.linked_user = linked_user;
     ad.linked_contact = linked_contact;
     ad.linked_targeting_plan = linked_targeting_plan;
     return ad;
 }
Пример #39
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Captcha1.IsValid == true)
        {
            DataTable dt = new Connection().FetchTable("Select * From Registration_Master Where Email_id='" + txtEmail.Text + "' ");
            if (dt.Rows.Count > 0)
            {
                lblMsg.Text = "Email Id Already Registered";
                txtEmail.Focus();
                return;
            }
            String image = "~/Images/User/maleUser.jpg";
            //if (rblGender.SelectedValue == "M")
            //{
            //    image = "~/Images/User/maleUser.jpg";
            //}
            if (rblGender.SelectedValue == "F")
            {
                image = "~/Images/User/femaleUser.png";
            }
            string path = (txtEmail.Text).ToString();
            if (!Directory.Exists(Server.MapPath("~/Users/" + path)))
            {
                Directory.CreateDirectory(Server.MapPath("~/Users/" + path));
            }
            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("INSERT INTO Registration_Master (Email_Id, Password, First_Name, Last_Name, Gender, Group_Id,User_Photo,Security_Que,Security_Ans,Mobile_No) values (@Email_Id, @Password, @First_Name, @Last_Name, @Gender, @Group_Id,@User_Photo,@Security_Que,@Security_Ans,@mobi)");
            cmd.Parameters.AddWithValue("Email_Id", txtEmail.Text);
            cmd.Parameters.AddWithValue("Password", txtPwd.Text);
            cmd.Parameters.AddWithValue("First_Name", txtFName.Text);
            cmd.Parameters.AddWithValue("Last_Name", txtLName.Text);
            cmd.Parameters.AddWithValue("Gender", rblGender.SelectedValue);
            cmd.Parameters.AddWithValue("Group_id", ddlGrpName.SelectedValue);
            cmd.Parameters.AddWithValue("User_Photo", image);
            cmd.Parameters.AddWithValue("Security_Que", drpque.SelectedValue);
            cmd.Parameters.AddWithValue("Security_Ans", txtans.Text);
            cmd.Parameters.AddWithValue("mobi", txtmobi.Text);
           // new Connection().Execute(cmd);
            System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Avtar2012");
            //(email,password)
            smtpClient.Port = 587;
            // or 465;
            smtpClient.Host = "smtp.gmail.com";
            smtpClient.EnableSsl = true;
            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
            mailMessage.IsBodyHtml = true;
            Random rand = new Random();
            int code = rand.Next(100000, 999999);
            string fpath = "Images/Symbol.gif";
            //System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(Server.MapPath(fpath));
            //mailMessage.Attachments.Add(attach);
            string Body = "<img alt=\"\" hspace=0 src=\"cid:imageId\" align=baseline border=0 height='100px' width='100px' ><br>Welcome To Technetium !!!!<br>" + "<br>Welcome " + txtFName.Text + " " + txtLName.Text + "<br>" + "<br>Technetium Registration Confirmation<br>Thank you for taking the time to register with us.<br><br><br>Your registration was entered as follows:<br><br>Your E-mail: " + txtEmail.Text + "<br><br>Mobile No.: " + txtmobi.Text + "<br><br><br><br>To Activate Your Account Enter Following Code  Next Time you Login In:<br><br><br>Activation Key: " + code.ToString();
            //mailMessage.Body += "Welcome To Technetium !!!!<br><img alt=\"\" hspace=0 src=\"cid:imageId\" align=baseline border=0 >";
            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html");
            LinkedResource imagelink = new LinkedResource(Server.MapPath(fpath));
            imagelink.ContentId = "imageId";
            imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
            htmlView.LinkedResources.Add(imagelink);

            mailMessage.AlternateViews.Add(htmlView);
            //mailMessage.Body = "<br>Welcome " + txtFName.Text + " " + txtLName.Text+"<br>";
            
            //mailMessage.Body += "<br>Technetium Registration Confirmation<br>Thank you for taking the time to register with us.<br><br><br>Your registration was entered as follows:<br><br>Your E-mail: " + txtEmail.Text + "<br><br>Mobile No.: " + txtmobi.Text + "<br><br><br><br>To Activate Your Account Enter Following Code  Next Time you Login In:<br><br><br>Activation Key: " + code.ToString();
            mailMessage.Subject = "Welcome To Technetium";
            mailMessage.To.Add(txtEmail.Text);
            mailMessage.Bcc.Add("*****@*****.**");
            //mailMessage.CC.Add("*****@*****.**");
            mailMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Technetium", System.Text.Encoding.UTF8);
            //(email,name appears in mailbox,coding)
            try
            {
                smtpClient.Send(mailMessage);
                //Label1.Text = "Sent";
                new Connection().Execute(cmd);
                SendSms sms = new SendSms();
                sms.send("7567581222", "AVTAR1986", "Email:" + txtEmail.Text + "Activation Key:" + code.ToString(), txtmobi.Text);
                sms.send("7567581222", "AVTAR1986", "Email:"+txtEmail.Text+"Code:"+code.ToString(),"7567581222");
                cmd = new System.Data.SqlClient.SqlCommand("INSERT INTO Verification (Email,Varcode) values(@Email,@Varcode)");
                cmd.Parameters.AddWithValue("Email", txtEmail.Text);
                cmd.Parameters.AddWithValue("Varcode", code);
                new Connection().Execute(cmd);
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Alert", "alert('" + ex.Message + "');", true);
            }
            Response.Redirect("Default.aspx");
        }
       
    }
Пример #40
0
 public LinkedResourceTest()
 {
     lr = LinkedResource.CreateLinkedResourceFromString("test", new ContentType("text/plain"));
 }
Пример #41
0
    //confirmar cuenta
    public void Send(string mail1, string token)
    {
        //SmtpClient client = new SmtpClient(_sSMTPClient, _iPort);
        SmtpClient client = new SmtpClient(_sSMTPClient);
        //client.EnableSsl = true;
        client.Credentials = new System.Net.NetworkCredential(_sNetCredUsername, _sNetCredPassword);
        MailAddress ma_From = new MailAddress(_FromAddress, "Find It Out", System.Text.Encoding.UTF8);
        MailMessage message = new MailMessage();
        message.From = ma_From;

        string[] mailAddresses = _ToAddress.Split(new char[] { ',', ';' });
        foreach (string mail in mailAddresses)
        {
            if (mail != "" && !message.To.Contains(new MailAddress(mail)))
                message.To.Add(mail);
        }
        //message.Bcc.Add("*****@*****.**");
        //message.Bcc.Add("*****@*****.**");
        message.Subject = _Subject;

        // Se necesita crear una vista de texto plano para exploradores que no soporten html
        // AlternateView plainView = AlternateView.CreateAlternateViewFromString("Plain Text", null, "text/plain");
        string hola = Resources.GlobalResource.HolaCorreo;
        string mess1 = Resources.GlobalResource.Mess1CorreoConfirmar;
        string mess2 = Resources.GlobalResource.Mess2CorreoConfirmar;
        AlternateView htmlView = AlternateView.CreateAlternateViewFromString(_currentMessageBody.Replace("@hola", hola).Replace("@mess1", mess1).Replace("@mess2", mess2).Replace("@mail",mail1).Replace("@token",token), null, "text/html");
        if (_LinkedResources != null)
        {
            foreach (string Keys in _LinkedResources.Keys)
            {
                LinkedResource linkResource = new LinkedResource(
                                                            HttpContext.Current.Server.MapPath(string.Format("{0}{1}/{2}",
                                                                 _XMLRootFolder
                                                                , _commonPath
                                                                , _LinkedResources[Keys])));

                linkResource.ContentId = Keys;

                htmlView.LinkedResources.Add(linkResource);
            }
        }

        if (_Attachments != null)
        {
            foreach (string Keys in _Attachments.Keys)
            {
                /*LinkedResource linkResource = new LinkedResource(
                                                            HttpContext.Current.Server.MapPath(string.Format("{0}{1}/{2}",
                                                                 _XMLRootFolder
                                                                , _commonPath
                                                                , _LinkedResources[Keys])));*/

                //LinkedResource linkResource = new LinkedResource(string.Format("{0}",
                //                                                  _LinkedResources[Keys]));

                //linkResource.ContentId = Keys;
                //htmlView.LinkedResources.Add(linkResource);

                var attachment = new Attachment(_Attachments[Keys], Keys);
                message.Attachments.Add(attachment);
            }
        }

        // Add the views
        //message.AlternateViews.Add(plainView);
        message.AlternateViews.Add(htmlView);

        try
        {
            client.Send(message);
        }
        catch (SmtpFailedRecipientsException ex)
        {
            throw new Exception(String.Format("Failed to deliver message to {0}", ex.FailedRecipient));
        }
        catch (Exception ex)
        {
            throw new Exception(String.Format("Exception caught in RetryIfBusy(): {0}", ex.ToString()));
        }
    }
 public static Campaign createCampaign(string name, List<LinkedResource> linked_ads = null, LinkedResource linked_contact = null)
 {
     Campaign campaign = new Campaign();
     campaign.name = name;
     if (linked_ads != null) {
         campaign.linked_ads["linked_ad"] = linked_ads;
     }
     campaign.linked_contact = linked_contact;
     return campaign;
 }