mailer question

  • Thread starter Web Search Store
  • Start date
W

Web Search Store

Hello,

I made a mailer program from instructions I found on the web in vb2005.

It works, but doesn't seem to send the mail until I end the program.

Maybe there is some other command I need to get it to send?

Any help appreciated.

I know this is true, because my outgoing mail virus scan pops up when I
close the program, showing its scanning an outgoing email.

This doesn't happen till I end the program.

After that I get the message in my in box. Not while the program is up,
even though it says it sent.

Thanks.

Scott
Dim msg As New MailMessage("(e-mail address removed)", "(e-mail address removed)")

msg.Subject = "My Email Subject"

msg.IsBodyHtml = True

msg.Body = "This is <i>the body</i> of the email message, it can also
contain HTML code in it"

Dim credential As Net.NetworkCredential = New Net.NetworkCredential

credential.UserName = "(e-mail address removed)"

credential.Password = "forward"

'Now we 've got everything we need to send the email except an SMTP server.
To create that just create a new instance of SmtpClient.

Dim client As New Net.Mail.SmtpClient()

'First we need to set up which SMTP server that the SMTP Client needs to use

client.Host = "mail.mysite.com"

client.UseDefaultCredentials = False

client.Credentials = credential

'client.EnableSsl = True

'The first line tells the SMTP client that we are supplying our own
credentials. The second line sets those credentials to the
NetworkCredentials we set up earlier. The third line tells the SmtpClient
that gmail uses SSL for authentication.

'Everything is ready to go now, all that is needed is to send the message.
Just call the send method supplying the MailMessage we created earlier.

client.Send(msg)

'client.SendAsync("(e-mail address removed)", "(e-mail address removed)", "hi", "hi more",
"")
 
K

kimiraikkonen

Hello,

I made a mailer program from instructions I found on the web in vb2005.

It works, but doesn't seem to send the mail until I end the program.

Maybe there is some other command I need to get it to send?

Any help appreciated.

I know this is true, because my outgoing mail virus scan pops up when I
close the program, showing its scanning an outgoing email.

This doesn't happen till I end the program.

After that I get the message in my in box.  Not while the program is up,
even though it says it sent.

Thanks.

Scott
Dim msg As New MailMessage("(e-mail address removed)", "(e-mail address removed)")

msg.Subject = "My Email Subject"

msg.IsBodyHtml = True

msg.Body = "This is <i>the body</i> of the email message, it can also
contain HTML code in it"

Dim credential As Net.NetworkCredential = New Net.NetworkCredential

credential.UserName = "(e-mail address removed)"

credential.Password = "forward"

'Now we 've got everything we need to send the email except an SMTP server..
To create that just create a new instance of SmtpClient.

Dim client As New Net.Mail.SmtpClient()

'First we need to set up which SMTP server that the SMTP Client needs to use

client.Host = "mail.mysite.com"

client.UseDefaultCredentials = False

client.Credentials = credential

'client.EnableSsl = True

'The first line tells the SMTP client that we are supplying our own
credentials. The second line sets those credentials to the
NetworkCredentials we set up earlier. The third line tells the SmtpClient
that gmail uses SSL for authentication.

'Everything is ready to go now, all that is needed is to send the message.
Just call the send method supplying the MailMessage we created earlier.

client.Send(msg)

'client.SendAsync("(e-mail address removed)", "(e-mail address removed)", "hi", "hi more",
"")

client.send(msg) is should be the last code line for your mail
sending. BTW, you should have detailed what you mean by saying "It
works, but doesn't seem to send the mail until I end the program".
 
T

Trevor Benedict

Have you tried to dispose all variables after you exit this sendmail
routine.

Regards,

Trevor Benedict
MCSD
 

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

Top