matt cupryk

matt cupryk

  • NA
  • 29
  • 0

Email is send twice.

Apr 4 2011 12:43 AM
protected void btnSend_Click(object sender, EventArgs e)
{
Page.Validate();
if (Page.IsValid)
{
btnSend.Attributes["disabled"] = "disabled";
System.Threading.Thread.Sleep(2000);
string subject = txtSubject.Text.Trim();
string message = txtMessage.Text.Trim();
string toUser = null;
string ToUserName = null;
string FromUserName = null;

var replyToPM = SQLOmegaLoveProvider.GetPrivateMessageByID(this.ReplyToMessageId);
if (replyToPM != null)
{
if (replyToPM.ToProfileID == SQLOmegaLoveProvider.GetCurrentUserProfileID() || replyToPM.FromProfileID == SQLOmegaLoveProvider.GetCurrentUserProfileID())
{
toUser = lblToUserName.Text;
}
else
{
Response.Redirect("~/Secure/PrivateMessages.aspx");
}
}
else
{
if (Request.QueryString["UserNameID"] != null)
toUser = SQLOmegaLoveProvider.GetUserNameByProfileID(Convert.ToInt32(Request.QueryString["UserNameID"]));
}

if (toUser == null)
{
Response.Redirect("~/Secure/PrivateMessages.aspx");
}

ToUserName = SQLOmegaLoveProvider.GetUserNameByProfileID(Convert.ToInt32(ToProfileID));
FromUserName = SQLOmegaLoveProvider.GetUserNameByProfileID(FromProfileID);


var pm = SQLOmegaLoveProvider.InsertPrivateMessage(FromProfileID, ToProfileID,
subject, message, false, false, false, DateTimeHelper.ConvertToUtcTime(DateTime.Now));

System.Threading.Thread.Sleep(2000);
SMTPManager.SendPrivateMessage(FromUserName, ToUserName);

txtSubject.Text = "";
txtMessage.Text = "";

Response.Redirect("~/Secure/PrivateMessages.aspx?tab=sent");

}
}

Need to fix the above and have inside the txtmessage indicator being sent.

Answers (3)