Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When Paypal notifyback will trigger my methed in my controller.
Yes the method is indeed trigger, And except the send email function don't work

if (amountPaid == price)
               {
                   if (payment_status.ToLower() == &completed)
                   {
                       //update the database table function over there 
                       //it works
                      //Send Parse Email to company  system                    

                        SendParseEmail(clientID);//this didn't work
////send a comfirmation email withe QR code
                        ////send email to the client
                       
                            SendClientEmail(clientID);
                       }
               ///follow code all working correcting
//....


  public void SendParseEmail(int clientID)
        {
            //there are a lot of code just for get information from database               

                     var mailMessage = new MailMessage();
                     mailMessage.From = new MailAddress("xxxx@xxx.xxx");
                     mailMessage.To.Add("xxx@xxx.xxx");// 

                     mailMessage.Body = mm_Form.ToString();
                     mailMessage.IsBodyHtml = false;
                
                 
                 Thread parseEmail = new Thread(delegate()
                 {
                     var mysmtpParse = new SmtpClient();
                     mysmtpParse.Send(mailMessage);
                 });
                 parseEmail.IsBackground = true;
                 parseEmail.Start();

             }
        }

 public void SendClientEmail(int clientID)
        {
            string fileName = Server.MapPath("~/Common/ClientEmail.html");
            string mailBody = System.IO.File.ReadAllText(fileName);
            if(book.ContactName==null)
                mailBody = mailBody.Replace("##ContactName##", book.UserName);
            else
                mailBody = mailBody.Replace("##ContactName##", book.ContactName);
            mailBody = mailBody.Replace("##Email##", book.Email);
            if(book.Phone2==null)
                mailBody = mailBody.Replace("##HomePhone##", book.Phone);
            else
                mailBody = mailBody.Replace("##HomePhone##", book.Phone2);
            mailBody = mailBody.Replace("##Pickup##", PickupInfo);
            mailBody = mailBody.Replace("##Destination##", DropoffInfo);
            mailBody = mailBody.Replace("##Vehicle##", "Shuttle");
            mailBody = mailBody.Replace("##numAdults##", numOfPaxStr);
            mailBody = mailBody.Replace("##UnitAdultPrice##", unitOfPriceStr);            
            mailBody = mailBody.Replace("##TotalPrice##", totalPrice);
            mailBody = mailBody.Replace("##PaidDate##", paidDay); 
            mailBody = mailBody.Replace("##PaidAmount##", amountPaid.ToString()); 


            var myMessage = new MailMessage();

            myMessage.Subject = "Shuttle Booking:" + book.Ref + "(" + cityName + "): Tax Invoice, Travel Details & Receipt";
            myMessage.Body =  mailBody;
            myMessage.IsBodyHtml = true;

            myMessage.From = new MailAddress("xxx@xxx.xxx", "Royale Airport Transfer Bookings");//enquiries@royalecoach.com.au
            myMessage.To.Add(new MailAddress(payer_email, userName));
            
           
            Thread clientEmail = new Thread(delegate()
            {
                var mysmtpClient = new SmtpClient();
                mysmtpClient.Send(myMessage);
            });
            clientEmail.IsBackground = true;
            clientEmail.Start();

        }
Posted
Updated 26-Nov-14 14:47pm
v2

It's possible that you are sending it nowhere. The SmtpClient constructor you are using is based on assumption that you chose you SMTP server and all the parameter by writing appropriate configuration file:
http://msdn.microsoft.com/en-us/library/k1c4h6e2%28v=vs.110%29.aspx[^].

Who knows what did you write in that configuration file, if it even exists? :-)

To explicitly choose the server or server with the port, you would need to use other constructors:
http://msdn.microsoft.com/en-us/library/k0y6s613(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/67w4as51(v=vs.110).aspx[^].

Besides, if everything is done, I cannot be sure that you used correct parameters for the server and authentication. You can do this: try the server you have with some available mail client program, and when you make sure it really sends messages, mimic all the parameters in your code.

—SA
 
Share this answer
 
It has been sovled by myself, I have some parameter is not correct
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900