Sending mail.

  • Thread starter Thread starter Phoebe.
  • Start date Start date
P

Phoebe.

Hi, Good Day!

I am writing a code in order to send a mail out when certain job failed
while running the program. Meanwhile for my testing, I'm either hardcoding
the address or type in on the spot so that the mail will be send as expected
to certain people. The code is as below.
Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As EventArgs)

Dim TheMailMessage As New Mail.MailMessage()

Dim TheMailConnection As SmtpMail

TheMailMessage.From = txtFromEmail.Text

TheMailMessage.To = txtToEmail.Text

TheMailMessage.Subject = txtSubject.Text

TheMailMessage.Body = txtMessage.Text

TheMailConnection.Send(TheMailMessage)

End Sub

What I need is to send the mail automatically when the program facing
error. How shd I do? Can someone help?

Thanks in advanced.

rgds, Phoebe.
 
Thanks Steve.

My main concern is to send out mail without hardcode those emailTo,
emailFrom address. Can i save these email address in a file, maybe like
notepad or something else.

Thanks in advanced.

rgds,
Phoebe.
 
There are lots of places you could store that information, but I can't tell
you which is best since I don't know the details of your app.
Off the top of my head I'd think some likely places would be Session,
Application, Cache, a database, a text or xml file, etc.
 
Keep your Email Id's in Web.Config file.
define keys for each EmailTO, email from......

you have amny options after that, either read the email-id's when ever u require to send mails or on the application start event read the Email-Ids/Setting from the Web.Config file and load it into Application object/Cahce object but not session... as session is user specific.

hope it helps
Rajeev
 
Back
Top