コード例 #1
0
        //Sending Invitation
        public void sendMsgInvite(GuestModel _guest, EventModel _event, string pass, int EventID)
        {
            EventAddress  addres     = new EventAddress();
            MappingClient add_client = new MappingClient();

            addres = add_client.getAddressById(Convert.ToString(_event.EventAddress));

            EventHostModel    host    = new EventHostModel();
            HostServiceClient ev_host = new HostServiceClient();

            host = ev_host.findhsotbyID(Convert.ToString(_event.HostID));
            SmtpClient smtp = new SmtpClient();

            smtp.Host        = "smtp.gmail.com";
            smtp.Port        = 587;
            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "*****@*****.**");
            smtp.EnableSsl   = true;

            MailMessage msg = new MailMessage();

            msg.Subject = "Invitation to the " + _event.Name;
            msg.Body    = "Hi " + _guest.NAME + ",";
            msg.Body   += "<tr><td>EventriX would like to invite you to attend the " + _event.Desc + "</td></tr>";
            msg.Body   += "<tr>";
            msg.Body   += "<td><img src='" + _event.ImageLocation + "' alt=''/></td>";
            msg.Body   += "</tr>";
            msg.Body   += "<tr>";
            msg.Body   += "<td>" + _event.eDate + "</td>";
            msg.Body   += "</tr>";
            msg.Body   += "<tr>";
            msg.Body   += "<td> Location: " + addres.STREET + ", " + addres.CITY + ", " + addres.PROVINCE + "</td>";
            msg.Body   += "</tr>";
            msg.Body   += "<tr>";
            //http://localhost:60469/Login.aspx?e_ID=
            //
            msg.Body += "<td>To RSVP please <a href='http://*****:*****@gmail.com";

            msg.From       = new MailAddress(FromAddress);
            msg.IsBodyHtml = true;

            try
            {
                smtp.Send(msg);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }