示例#1
0
        public string SendMailByMandrillForEnterprise(string name, string Host, int port, string from, string passsword, string to, string bcc, string cc, string subject, string body, string sendgridUserName, string sendgridPassword)
        {
            string res = string.Empty;

            try
            {
                //username = ConfigurationManager.AppSettings["Mandrillusername"];
                Host = ConfigurationManager.AppSettings["Mandrillhost"];

                port = Convert.ToInt32(ConfigurationManager.AppSettings["Mandrillport"]);

                sendgridPassword = ConfigurationManager.AppSettings["Mandrillpassword"];

                //from = ConfigurationManager.AppSettings["fromemail"];

                GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();

                res = objMailHelper.SendMailByMandrillForEnterPrise(name, Host, port, from, passsword, to, bcc, cc, subject, body, sendgridUserName, sendgridPassword);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
            }
            return(res);
        }
示例#2
0
        public string AddTeam(string UserId, string InviteStatus, string FirstName, string LastName, string EmailId, string AccessLevel, string GroupId, string useremail, string username)
        {
            try
            {
                if (!teamrepo.checkTeamExists(EmailId, Guid.Parse(UserId), Guid.Parse(GroupId)))
                {
                    team.Id = Guid.NewGuid();
                    team.UserId = Guid.Parse(UserId);
                    team.InviteStatus = Convert.ToInt32(InviteStatus);
                    team.InviteDate = DateTime.Now;
                    team.StatusUpdateDate = DateTime.Now;
                    team.GroupId = Guid.Parse(GroupId);
                    team.StatusUpdateDate = DateTime.Now;
                    team.FirstName = FirstName;
                    team.LastName = LastName;
                    team.EmailId = EmailId;
                    team.AccessLevel = AccessLevel;
                    teamrepo.addNewTeam(team);
                    string check = team.Id.ToString();

                    string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/GroupInvitation.html");
                    string html = File.ReadAllText(mailpath);
                    html = html.Replace("[join link]", ConfigurationManager.AppSettings["MailSenderDomain"] + "Home/Index?teamid=" + team.Id.ToString());
                    string usernameSend = ConfigurationManager.AppSettings["Mandrillusername"];
                    string host = ConfigurationManager.AppSettings["Mandrillhost"];
                    string port = ConfigurationManager.AppSettings["Mandrillport"];
                    string pass = ConfigurationManager.AppSettings["Mandrillpassword"];
                    GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();
                    objMailHelper.SendMailByMandrill(host, Convert.ToInt32(port), useremail, username, "", EmailId, "", "", "Group Invitation", html, usernameSend, pass);

                    return new JavaScriptSerializer().Serialize(team);
                }
                else
                {
                    return "";
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
示例#3
0
        public string AddTeam(string UserId, string InviteStatus, string FirstName, string LastName, string EmailId, string AccessLevel, string GroupId, string useremail, string username)
        {
            try
            {
                if (!teamrepo.checkTeamExists(EmailId, Guid.Parse(UserId), Guid.Parse(GroupId)))
                {
                    team.Id               = Guid.NewGuid();
                    team.UserId           = Guid.Parse(UserId);
                    team.InviteStatus     = Convert.ToInt32(InviteStatus);
                    team.InviteDate       = DateTime.Now;
                    team.StatusUpdateDate = DateTime.Now;
                    team.GroupId          = Guid.Parse(GroupId);
                    team.StatusUpdateDate = DateTime.Now;
                    team.FirstName        = FirstName;
                    team.LastName         = LastName;
                    team.EmailId          = EmailId;
                    team.AccessLevel      = AccessLevel;
                    teamrepo.addNewTeam(team);
                    string check = team.Id.ToString();

                    string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/GroupInvitation.html");
                    string html     = File.ReadAllText(mailpath);
                    html = html.Replace("[join link]", ConfigurationManager.AppSettings["MailSenderDomain"] + "Home/Index?teamid=" + team.Id.ToString());
                    string usernameSend = ConfigurationManager.AppSettings["Mandrillusername"];
                    string host         = ConfigurationManager.AppSettings["Mandrillhost"];
                    string port         = ConfigurationManager.AppSettings["Mandrillport"];
                    string pass         = ConfigurationManager.AppSettings["Mandrillpassword"];
                    GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();
                    objMailHelper.SendMailByMandrill(host, Convert.ToInt32(port), useremail, username, "", EmailId, "", "", "Group Invitation", html, usernameSend, pass);

                    return(new JavaScriptSerializer().Serialize(team));
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return("Something Went Wrong");
            }
        }
示例#4
0
        //[WebMethod]
        //[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
        public string SendNewsLetter(string body, string Subject, string userid, string NewsLetterId)
        {
            UserRepository objUserRepository = new UserRepository();

            Domain.Socioboard.Domain.User objUser = new Domain.Socioboard.Domain.User();
            string res = string.Empty;
            string ret = string.Empty;

            try
            {
                string from     = ConfigurationManager.AppSettings["fromemail"];
                string tomail   = ConfigurationManager.AppSettings["tomail"];
                string username = ConfigurationManager.AppSettings["Mandrillusername"];
                string host     = ConfigurationManager.AppSettings["Mandrillhost"];
                string port     = ConfigurationManager.AppSettings["Mandrillport"];
                string pass     = ConfigurationManager.AppSettings["Mandrillpassword"];


                //string sss = ConfigurationSettings.AppSettings["host"];
                objUser = objUserRepository.getUsersById(Guid.Parse(userid));

                GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();

                ret = objMailHelper.SendMailByMandrill(host, Convert.ToInt32(port), from, "", objUser.EmailId, string.Empty, string.Empty, Subject, body, username, pass);
                //NewsLetterRepository objNewsLetterRepository = new NewsLetterRepository();

                if (ret.Contains("Success"))
                {
                    ObjNewsLetter.Id         = Guid.Parse(NewsLetterId);
                    ObjNewsLetter.SendStatus = true;
                    ObjNewsLetterRepository.UpdateNewsLetter(ObjNewsLetter);
                    //lstbox.Items.Add("Mail send to : " + objUser.UserName);
                }
                //return ret;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
            return(ret);
        }
示例#5
0
        public static void SendSendGridMail(string Host, int port, string from, string passsword, string to, string bcc, string cc, string subject, string body, string sendgridUserName, string sendgridPassword)
        {
            try
            {
                var myMessage = SendGridMail.SendGrid.GetInstance();
                myMessage.From = new System.Net.Mail.MailAddress(from);
                myMessage.AddTo(to);
                myMessage.Subject = subject;

                //Add the HTML and Text bodies
                myMessage.Html = body;
                //myMessage.Text = "Hello World plain text!";
                var username = sendgridUserName;
                var pswd     = sendgridPassword;

                var credentials  = new System.Net.NetworkCredential(username, pswd);
                var transportWeb = SMTP.GetInstance(credentials);

                // Send the email.
                //transportWeb.Deliver(myMessage);

                MailHelper objMailHelper = new MailHelper();
                string     res           = objMailHelper.SendMailByMandrill(Host, port, from, passsword, to, bcc, cc, subject, body, sendgridUserName, sendgridPassword);
            }
            catch (Exception ex)
            {
                try
                {
                    GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();

                    string res = objMailHelper.SendMailByMandrill(Host, port, from, passsword, to, bcc, cc, subject, body, sendgridUserName, sendgridPassword);
                }
                catch (Exception)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }
            }
        }
示例#6
0
        public string SendMailByMandrill(string Host, int port, string from, string passsword, string to, string bcc, string cc, string subject, string body, string sendgridUserName, string sendgridPassword)
        {
            string res = string.Empty;
            try
            {
                //username = ConfigurationManager.AppSettings["Mandrillusername"];
                Host = ConfigurationManager.AppSettings["Mandrillhost"];

                port = Convert.ToInt32(ConfigurationManager.AppSettings["Mandrillport"]);

                sendgridPassword = ConfigurationManager.AppSettings["Mandrillpassword"];

                from = ConfigurationManager.AppSettings["fromemail"];

                GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();

                res = objMailHelper.SendMailByMandrill(Host, port, from, passsword, to, bcc, cc, subject, body, sendgridUserName, sendgridPassword);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
            }
            return res;
        }
示例#7
0
        public static void SendSendGridMail(string Host, int port, string from, string passsword, string to, string bcc, string cc, string subject, string body,string sendgridUserName,string sendgridPassword)
        {
            try
            {

                    var myMessage = SendGridMail.SendGrid.GetInstance();
                    myMessage.From = new System.Net.Mail.MailAddress(from);
                    myMessage.AddTo(to);
                    myMessage.Subject = subject;

                    //Add the HTML and Text bodies
                    myMessage.Html = body;
                    //myMessage.Text = "Hello World plain text!";
                    var username = sendgridUserName;
                    var pswd = sendgridPassword;

                    var credentials = new System.Net.NetworkCredential(username, pswd);
                    var transportWeb = SMTP.GetInstance(credentials);

                    // Send the email.
                    //transportWeb.Deliver(myMessage);

                    MailHelper objMailHelper = new MailHelper();
                    string res = objMailHelper.SendMailByMandrill(Host, port, from, passsword, to, bcc, cc, subject, body, sendgridUserName, sendgridPassword);

            }
            catch (Exception ex)
            {
                try
                {
                    GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();

                    string res=objMailHelper.SendMailByMandrill(Host, port, from, passsword, to, bcc, cc, subject, body, sendgridUserName, sendgridPassword);
                }
                catch (Exception)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.Message);
                }

            }
        }
        //[WebMethod]
        //[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
        public string SendNewsLetter(string body, string Subject, string userid,string NewsLetterId)
        {
            
            UserRepository objUserRepository = new UserRepository();
            Domain.Myfashion.Domain.User objUser = new Domain.Myfashion.Domain.User();
            string res = string.Empty;
            string ret = string.Empty;
            try
            {


                string from = ConfigurationManager.AppSettings["fromemail"];
                string tomail = ConfigurationManager.AppSettings["tomail"];
                string username = ConfigurationManager.AppSettings["Mandrillusername"];
                string host = ConfigurationManager.AppSettings["Mandrillhost"];
                string port = ConfigurationManager.AppSettings["Mandrillport"];
                string pass = ConfigurationManager.AppSettings["Mandrillpassword"];


                //string sss = ConfigurationSettings.AppSettings["host"];
                objUser = objUserRepository.getUsersById(Guid.Parse(userid));

                GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();

                ret = objMailHelper.SendMailByMandrill(host, Convert.ToInt32(port), from, "", objUser.EmailId, string.Empty, string.Empty, Subject, body, username, pass);
                //NewsLetterRepository objNewsLetterRepository = new NewsLetterRepository();

                if (ret.Contains("Success"))
                {
                    ObjNewsLetter.Id = Guid.Parse(NewsLetterId);
                    ObjNewsLetter.SendStatus = true;
                    ObjNewsLetterRepository.UpdateNewsLetter(ObjNewsLetter);
                    //lstbox.Items.Add("Mail send to : " + objUser.UserName);
                }
                //return ret;

                
            }
            catch (Exception ex)
            {

                Console.WriteLine("Error : " + ex.StackTrace);
            }
            return ret;
        }