Advertisement
Guest User

The message could not be sent to the SMTP server. The transp

a guest
Jul 3rd, 2015
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7.  
  8. using ClassLibrary.model;
  9. using ClassLibrary.DBMon;
  10. using ClassLibrary.utility;
  11. using ClassLibrary;
  12. using System.Data;
  13. using System.IO;
  14. using System.Net;
  15. using System.Threading;
  16. using System.Text;
  17. using System.Web.Mail;
  18.  
  19. namespace BollyWoodArtists.Admin
  20. {
  21.     public partial class home : System.Web.UI.Page
  22.     {
  23.         register1 ObjMember = new register1();
  24.  
  25.         protected void Page_Load(object sender, EventArgs e)
  26.         {
  27.             if (Session["MemberId"] == null)
  28.             {
  29.                 Response.Redirect("~/login.aspx");
  30.             }
  31.             if (!IsPostBack)
  32.             {
  33.                 LookForExpiredAccounts();
  34.                 DataTable Settings = ObjMember.getSettingsTbl();
  35.                 txtNoofdays.Text = Settings.Rows[0]["FreeMonths"].ToString();
  36.                 if (Settings.Rows[0]["FreeMode"].ToString() == "1")
  37.                 {
  38.                     rdbFee.Checked = true;
  39.                     rdbPayment.Checked = false;
  40.                 }
  41.                 else
  42.                 {
  43.                     rdbFee.Checked = false;
  44.                     rdbPayment.Checked = true;
  45.                 }
  46.                
  47.             }
  48.            
  49.         }
  50.  
  51.         protected void Submit_Click(object sender, EventArgs e)
  52.         {
  53.             ObjMember.PasswordReset(txtNewPassword.Text, 1);
  54.             Response.Write("<script>alert('Your Password has been changed successfully')</script>");
  55.         }
  56.  
  57.         protected void btnPasswordResetClick(object sender, EventArgs e)
  58.         {
  59.             txtNewPassword.Text = "";
  60.             txtConfirmPassword.Text = "";
  61.         }
  62.  
  63.         protected void btnSettings_Click(object sender, EventArgs e)
  64.         {
  65.             int mode = 0;
  66.             if (rdbFee.Checked == true)
  67.             {
  68.                 mode = 1;
  69.             }
  70.             ObjMember.PostAuditionUpdate(txtNoofdays.Text, mode);
  71.  
  72.         }
  73.  
  74.         protected void btn_Submit_Click(object sender, EventArgs e)
  75.         {
  76.             string showreel, content;
  77.             if (radShow.Checked == true)
  78.             {
  79.                 showreel = "1";
  80.                 content = txtLocation.Text;
  81.             }
  82.             else if (radHide.Checked == true)
  83.             {
  84.                 showreel = "0";
  85.                 content = null;
  86.             }
  87.             else
  88.             {
  89.                 showreel = "0";
  90.                 content = null;
  91.             }
  92.             ObjMember.UpdateShowReel(showreel, content);
  93.             Response.Redirect("home.aspx");
  94.         }
  95.  
  96.         protected void LookForExpiredAccounts()
  97.         {
  98.             register1 ObjLogin = new register1();
  99.             DataTable expiredMembers = new DataTable();
  100.             clsAuditionsDisplay ObjAuditions = new clsAuditionsDisplay();
  101.             expiredMembers = ObjLogin.getMembersExpired();
  102.             if (expiredMembers != null)
  103.             {
  104.                 if (expiredMembers.Rows.Count != 0 && expiredMembers != null)
  105.                 {
  106.                     for (int i = 0; i < expiredMembers.Rows.Count; i++)
  107.                     {
  108.                         int MemberId = Convert.ToInt32(expiredMembers.Rows[i]["MemberId"].ToString());
  109.                         ObjAuditions.ChangeMemberStatustoExpiry1(MemberId);
  110.                         sendemail(MemberId, expiredMembers, i);
  111.                         SendSMS(expiredMembers, i);
  112.                     }
  113.                 }
  114.             }
  115.            
  116.         }
  117.  
  118.         public void sendemail(int MemberId, DataTable Member, int rowNo)
  119.         {
  120.             MailMessage msgMail = new MailMessage();
  121.  
  122.             msgMail.To = Member.Rows[rowNo]["EmailID"].ToString();
  123.             msgMail.From = "admin@auditionbollywood.com";
  124.             msgMail.Subject = "Auditions BollyWood Account Expire";
  125.             msgMail.BodyFormat = MailFormat.Text;
  126.             StringBuilder sb = new StringBuilder();
  127.             sb.AppendFormat("Hi !\n\n");
  128.             sb.AppendFormat("Your Audition Bollywood Account has been expired.Please pay the payment for activation.\n");
  129.             sb.AppendFormat("Click the below link to pay to activate your account\n");
  130.             string link = string.Format("http://www.auditionbollywood.com/paymentrenewal.aspx?MemberId={0}", MemberId.ToString());
  131.             sb.Append(link);
  132.             sb.AppendFormat("\n\nThank You");
  133.             msgMail.Body = sb.ToString();
  134.             msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "mail.auditionbollywood.com");
  135.             msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 587);
  136.             msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2);
  137.             msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
  138.             msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "admin@auditionbollywood.com");
  139.             msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "************");
  140.             SmtpMail.SmtpServer = "mail.auditionbollywood.com";
  141.             SmtpMail.Send(msgMail);
  142.         }
  143.  
  144.  
  145.         private void SendSMS(DataTable Member, int rowNo)
  146.         {
  147.             try
  148.             {
  149.                 StreamReader objReader;
  150.                 string Message = "Hi" + " " + Member.Rows[rowNo]["FirstName"].ToString() + " " + ",Your Audition Bollywood Account has been expired.";
  151.                 Uri myuri = new Uri("SMS SENDING TOKEN" + Member.Rows[rowNo]["MobilNo"].ToString() + "&message=" + Message);
  152.                 WebRequest myWebRequest = WebRequest.Create(myuri);
  153.  
  154.                 Stream objStream;
  155.                 objStream = myWebRequest.GetResponse().GetResponseStream();
  156.                 objReader = new StreamReader(objStream);
  157.                 objReader.Close();
  158.  
  159.             }
  160.             catch (Exception Ex)
  161.             {
  162.  
  163.             }
  164.         }
  165.     }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement