SpiceLogic Inc.
                                                                                                     SpiceLogic Inc. Home PageProductsJournalMy AccountHelp DeskContact Us
 
Knowledge base  : ASP.NET PayPal Control for Website Payments Standard    - Standard Edition
Welcome Guest   Login

Skip Navigation Links. ASP.NET PayPal Control for Website Payments Standard

Documentation  Documentation

Download   Download the latest version

Back to the home of knowledgebase forum How does the SendMail helper method work?

An user   4/27/2009 7:28:25 PM

Hi Nathan,

 

I have a couple of questions about the control.

 

First, how does the SendMail helper method work?  It does not ask for an SMTP server.  How does it send mail?

 

Last, when testing in the Sandbox using WebAccept/Instant, I get a status of Pending with a reason of Other and I never get a second IPN with a Completed status.  What gives?  Is this something peculiar to the Sandbox?

 

Thanks,

Brian




Resolution:
- [SpiceLogic Support Technician]   4/29/2009 4:49:27 AM

Hi Brian,
The Source Code for SendMail Helper Method is as follows:
 

    /// <summary>

        ///     Sends an email message based on given arguments. This email sending method

        ///     uses the email sending facility of your very server and it does not use any

        ///     external web services at all. It uses "localhost" to be the name of the SMTP

        ///     host.

        /// </summary>

        /// <returns><c>true</c> if mail sending succeeded, <c>false</c> if mail sending failed.</returns>

        /// <param name="toEmail">To email.</param>

        /// <param name="toName">To name.</param>

        /// <param name="fromEmail">From email.</param>

        /// <param name="fromName">From name.</param>

        /// <param name="subject">The subject.</param>

        /// <param name="message">The message.</param>

        /// <param name="isHTML">if set to <c>true</c> The message will be treated as Html message otherwise it will be treated as plain text message.</param>

        public static bool SendEmail(string toEmail, string toName, string fromEmail, string fromName, string subject, string message, bool isHTML)

        {

            MailAddress myToAddr = new MailAddress(toEmail, toName);

            MailAddress myFromAddr = new MailAddress(fromEmail, fromName);

            MailMessage myMessage = new MailMessage(myFromAddr, myToAddr)

                                        {

                                            Subject = subject,

                                            Body = message,

                                            IsBodyHtml = isHTML

                                        };

 

            SmtpClient myClient = new SmtpClient("localhost")

                                      {

                                          Credentials = System.Net.CredentialCache.DefaultNetworkCredentials

                                      };

            try

            {

                myClient.Send(myMessage);

                return true;

            }

            catch

            {

                return false;

            }

        }
 
About the Reason Code, you can cehck the real Reason Code string posted by PayPal by exploring the associated ipn variable with the property PostedData (NameValueCollection). Also you can see the whole IPN string by e.IPN.DecodedRawData. You can ask the SandBox specific questions to PayPal support team as issue could be related with your SandBox account.



Home  || Products  || Journal  || My Account  || HelpDesk  || Contact Us

Website and Software Copyright ©2010, SpiceLogic Inc., All Rights Reserved.