@Keidrick - No, the settings are not in web.config file. It's in the code
itself. I know it's better to have it in config file so that I dont have to
recompile the code if my smtp settings change. But will that make a
difference as far as my issue is concerned?
@Vaibhav - Here is the code -
string recipientName = txtStudFirstName.Text.Trim() + " " +
txtStudFamilyName.Text.Trim();
string recipientEmail = txtStudEmail.Text.Trim();
MailAddress sender = new MailAddress("
[email protected]", "ABC");
MailAddress recipient = new MailAddress(recipientEmail,
recipientName);
MailMessage message = new MailMessage(sender, recipient);
string body = GetEmailBody();
if (body != string.Empty)
{
// Message details
message.Body = body;
message.Subject = "Welcome!";
message.IsBodyHtml = true;
// Add sender as CC so that he gets a copy of the email for
his records.
message.CC.Add(sender);
// SMTP details
SmtpClient client = new
SmtpClient("valid-smtpclientaddress");
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("
[email protected]", "password");
client.SendAsync(message, string.Empty);
return true;
}
else
return false;
And both client.send and client.sendAsync work fine when page is not
deployed on IIS. I am using my university's email server for this purpose.
On Thu, Apr 8, 2010 at 8:52 AM, KeidrickP <[email protected]> wrote:
> have you put the configuration settings in your web.config file for the
> SMTP server that you are using?
>
> On Mon, Apr 5, 2010 at 12:32 PM, Mandar Kulkarni <
> [email protected]> wrote:
>
>> Hello,
>>
>> I have written some code in ASP.NET that sends an email to the user
>> once he submits a form. I am using SmtpClient class for that and email
>> are routed using mail server at my university. The emails are going
>> through fine when I run the code from Visual Studio directly i.e. when
>> page is not hosted on IIS. But when I deploy the page on IIS, the form
>> just spins after submit and never comes back.
>>
>> Any clues what might be the problem?
>>
>> Thanks,
>> Mandar
>>
>>
>> --
>> To unsubscribe, reply using "remove me" as the subject.
>>
>
>
>
> --
> Keidrick Pettaway
>
> http://kpettaway.com
>