AspNet.StarterKits.Classifieds.BusinessLogicLayer.AdsDB.SendResponse C# (CSharp) Method

SendResponse() public static method

public static SendResponse ( int adId, string senderName, string senderAddress, string comments ) : bool
adId int
senderName string
senderAddress string
comments string
return bool
		public static bool SendResponse(int adId, string senderName, string senderAddress, string comments)
		{
			bool sent = false;
			SiteSettings s = SiteSettings.GetSharedSettings();
			AdsDataComponent.AdsRow ad = GetAdById(adId);
			if (ad != null)
			{
				MembershipUser adUser = Membership.GetUser(ad.MemberName);
				if (adUser != null)
				{

					StringBuilder sb = new StringBuilder();
					sb.AppendFormat("A user has sent a response to your Ad '{0}' at {1}", ad.Title, s.SiteName);
					sb.AppendLine();

					sb.AppendLine();

					sb.AppendLine("The contact information of the user is below:");

					sb.AppendLine();

					sb.AppendLine("Name: " + senderName);
					sb.AppendLine("Email: " + senderAddress);

					sb.AppendLine();

					sb.AppendLine("User comments/questions:");
					sb.AppendLine(comments);

					sb.AppendLine();

					sb.AppendLine("You can respond to the user by using the Reply feature of your email client.");

					sb.AppendLine();
					sb.AppendLine(s.SiteName);
					sb.AppendLine(ClassifiedsHttpApplication.SiteUrl);


					string from = String.Format("{0} <{1}>", senderName, senderAddress);
					try
					{
						MailMessage m = new MailMessage(from, adUser.Email);
						m.Subject = "Response for Ad: " + ad.Title;
						m.Body = sb.ToString();
						SmtpClient client = new SmtpClient();
						client.Send(m);

						IncrementResponseCount(adId);
						sent = true;
					}
					catch
					{
						// Consider customizing the message for the EmailNotSentPanel in the ShowAds page.
						sent = false;
					}
				}
			}
			return sent;
		}