Example #1
0
        ////      const string SERVER = "relay-hosting.secureserver.net";
        ////MailMessage oMail = new System.Web.Mail.MailMessage();
        ////oMail.From = "emailaddress@domainname";
        ////oMail.To = "emailaddress@domainname";
        ////oMail.Subject = "Test email subject";
        ////oMail.BodyFormat = MailFormat.Html; // enumeration
        ////oMail.Priority = MailPriority.High; // enumeration
        ////oMail.Body = "Sent at: " + DateTime.Now;
        ////SmtpMail.SmtpServer = SERVER;
        ////SmtpMail.Send(oMail);
        ////oMail = null; // free up resources
        //public static string emailHeader()
        //{

        //    String strheader = "<table cellspacing='0' cellpadding='0' width='100%' border='0' align='center' style='border-bottom:#9a9a9a 1px solid;border-left:#9a9a9a 1px solid;width:600px;border-top:#9a9a9a 1px solid;border-right:#9a9a9a 1px solid'>";
        //    strheader += "<tr><td style='padding-left:20px'><a target='_blank' href='http://www.gaganz.ca/'><img border='0' src='http://www.gaganz.ca/images/logo.jpg' alt=''></a></td>";
        //    strheader += "<td valign='top' align='right' style='padding-right:20px;padding-top:5px'><a target='_blank' href='http://www.gaganz.ca/login/LogOn' style='font:bold 11px arial;color:#D80303;text-decoration:none'>Login</a></td></tr>";

        //    return strheader;
        //}

        //public static string emailFooter()
        //{

        //    String strFooter = "<tr><td style='padding-bottom:10px' colspan='2'><br />  Warm Regards,<br><b>Team Gaganz.com<br /></b></td></tr>";


        //    return strFooter;
        //}

        public static string sendEmailPass(String emailTo, string strbody1, Int32 moduleid)
        {
            string msg = "";

            try
            {
                plugingaganzEntities db = new plugingaganzEntities();



                //var item = (from m in db.tb_emailsDescriptions
                //            where m.SetModuleID == moduleid
                //            select m);
                //string strbody = strbody1 + "<br />";
                //string strSubject = "";
                //if (item.Count() > 0)
                //{
                //    var item1 = (from m in db.tb_emailsDescriptions
                //                 where m.SetModuleID == moduleid
                //                 select m).Single();
                //    strbody += item1.Description;
                //    strSubject = item1.EmailSubject;

                //}


                String strheader = "<table cellspacing='0' cellpadding='0' width='100%' border='0' align='center' style='border-bottom:#9a9a9a 1px solid;border-left:#9a9a9a 1px solid;width:600px;border-top:#9a9a9a 1px solid;border-right:#9a9a9a 1px solid'>";
                //strheader += "<tr><td style='padding-left:20px'><a target='_blank' href='http://www.gaganz.ca/'><img width='179' vspace='10' height='75' border='0' src='http://www.gaganz.ca/images/logo.jpg' alt=''></a></td>";
                //              strheader += "<td valign='top' align='right' style='padding-right:20px;padding-top:5px'><a target='_blank' href='http://www.gaganz.ca/login/LogOn' style='font:bold 11px arial;color:#D80303;text-decoration:none'>Login</a></td></tr>";


                String strFooter = "<tr><td style='padding-bottom:10px' colspan='2'><br />  Warm Regards,<br><b>Pacific West<br /></b></td></tr>";



                String strMiddle = "<tr><td style='padding-bottom:10px' colspan='2'> " + strbody1 + "</td></tr>";


                System.Net.Mail.MailMessage  mail = new System.Net.Mail.MailMessage();
                System.Net.NetworkCredential cred = new System.Net.NetworkCredential("*****@*****.**", "sup123");

                mail.To.Add(emailTo);
                mail.Subject = "User Name and Password Informatoin";

                mail.From = new System.Net.Mail.MailAddress("*****@*****.**");
                mail.Bcc.Add(new MailAddress("*****@*****.**"));
                mail.Bcc.Add(new MailAddress("*****@*****.**"));
                // mail.Bcc.Add(new MailAddress("*****@*****.**"));

                mail.Priority   = MailPriority.High;
                mail.IsBodyHtml = true;
                mail.Body       = strheader + strMiddle + strFooter;

                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("relay-hosting.secureserver.net");
                smtp.UseDefaultCredentials = false;

                smtp.Credentials = cred;

                smtp.EnableSsl = false;
                smtp.Port      = 25;

                smtp.Send(mail);
                msg = "Success";
            }
            catch (Exception ce)
            {
                msg = ce.Message;
            }

            return(msg);
        }