Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web email stuck in the queue folder

Status
Not open for further replies.

meckeard

Programmer
Aug 17, 2001
619
US
Hi all,

I am trying to send web based email thru ASP.NET and all the outbound messages get stuck in the queue folder.

The same server successfully sends email using classic ASP. It's just .NET that it has a problem with.

Here is a sample of my code in C#:

<script language="C#" runat="server">
void Page_Load(Object src, EventArgs E){

try
{
MailMessage objEmail = new MailMessage();
objEmail.To = ("meckeard2000@yahoo.com");
objEmail.From = ("meckeard2000@yahoo.com");
objEmail.Subject = ("This is a test email");
objEmail.Body = ("test");
SmtpMail.Send(objEmail);

Response.Write ("email sent");
}
catch
{
Response.Write ("email NOT sent");
}
}
</script>

I have tried both C# and VB.NET. Same results. The page does not throw an error and SMTP is running on the server (Windows 2000 server). Exchange is 5.5 running on its own server.

I searched the web and found many articles that were similar, but none offered any help.

Thanks,
Mark
 
I recently ran into the same problem, you might want to check your SMTP settings on the Exchange server. You must allow the IP address of your box to use the SMTP virtual server as a relay. There is lots of stuff on the web about this for exchange 5.5
 
I am just starting in the .Net world, so take my advice with a big grain of salt. We use vb.net. This is our code for sending email:

'setup mail object
Dim mail As New System.Web.Mail.MailMessage
mail.BodyFormat = System.Web.Mail.MailFormat.Html
mail.To = emailTo1
mail.From = emailFrom1
mail.Cc = emailCC1
mail.BodyFormat = System.Web.Mail.MailFormat.Html
mail.Subject = emailSubject1
mail.Body = emailBody1
System.Web.Mail.SmtpMail.SmtpServer="MAILSERVERNAME.DOMAIN.COM"

'send mail
System.Web.Mail.SmtpMail.Send(mail)

Note: all of the variables on the right are strings.

Our code works. I notice one difference between your code and ours. We specifically tell the computer to use the mail server.

We use html format, because we are sending internal email, and we know that everybody has a modern email client. That is kinda a cool option, because then you can use lotsa tags.
 
I agree with OhioSteve, you could also use the iP address of the mail server here is my code for this.


Dim objEmail As New mailmessage()
objEmail.From="" + insertlastname.text + "" + insertfirstname.text + ""
objEmail.To="maddrixc@dcitp.gov"
objEmail.Subject="Support Request " & result
objEmail.bodyformat= mailformat.html
objEmail.Body="Owner:;"+ name.text + "
SmtpMail.SmtpServer="192.168.3.18"
smtpmail.send(objEmail)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top