Emailing from app - Help!

G

Guest

Hello -

I am attempting to email error messages to myself in the event of an error.
I am using the following code:

Dim mail as New MailMessage()
Dim ErrorMessage = "The error description is as follows: " &
Server.GetLastError.ToString
mail.To = "(e-mail address removed)"
mail.From = "(e-mail address removed)"
mail.Subject = "Error in the Site"
mail.Priority = MailPriority.High
mail.BodyFormat = MailFormat.Text
mail.Body = ErrorMessage
mail.Body = "Testing Email from App"
SmtpMail.Send(mail)

I originally put it in the global.asax under Sub Application_Error(ByVal,
etc.) and included at the top:
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.Mail

I received nothing . . . nada . . . no email, no error message, nothing. I
then attempted to just email myself from a plain old aspx page, putting the
code in the click event of a button and taking out the error message
referrals. I still receive nothing. On debugging, it is showing that
everything is fine.

Next I tried sending to someone else on another pc, using their address in
the "To" portion. Again . . . nothing. I'm running Outlook and have no
problems emailing myself or the other PC from there.

I am using Visual Studio in an XP operating system. Is there some setting
somewhere I should check? Is there something drastically wrong with my code
above?

Any help you can give me will be greatly appreciated! This is starting to
drive me crazy . . .
 
T

TE

Hi Sandy,

you need to have access to a SMTP Mail-Server and provide those information,
to be able to send emails using the system.web.mail class.

SmtpMail.SmtpServer = "smtp.mailserver.whatever"

Regards,

Tom
 
G

Guest

Thanks for your reply, Tom.

Does that mean I have to install something like Exchange Server? I'm
currently only running Windows XP Professional. I have a mail account with
earthlink.net. I thought perhaps because I am able to email myself through
earthlink, I might be able to programmatically email myself.

I just wanted to be able to test the code for the time being until I get to
the point where I actually get a host, etc.

Sandy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top