views:

466

answers:

1

Hello,


I’d like for CreateUserWizard control to send email notifications to created users. Since I don’t host my own SMTP server, I tried to use my gmail account to send those notifications, but I kept getting “Must issue STARTTLS command first”. One site suggests this is due to CreateUserWizard’s SmtpClient using System.Net.Sockets.NetworkStream and not System.Net.Security.SslStream.

Thus only way I know how to configure CreateUserWizard control to send emails (via gmail) is by handling SendingMail event, where I have to cancel the event ( via MailMessageEventArgs.Cancel) and then manually create and send the email ( that way I'm able to set SmtpClient.EnableSsl to true ).

Is there a way to get a reference to CreateUserWizard's SmtpClient object and set its EnableSsl to true so that i don't have to manually send email notifications?


thanx

+1  A: 

I am affraid there is no other solution... There is a Suggestion on microsoft site for adding EnableSSL direcly to the smtp config... Until that the workaround is:

protected void CreateUserWizard1_OnSendingMail(object sender, MailMessageEventArgs e)
{
SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.Send(e.Message);
e.Cancel = true;
}
bogdanbrudiu