There are many ways to sent email from VB, and while it is quite possible to do it with the MAPI control, i found a much simpler way, using a webbrowser control and an ASP page. My code simply retrieves the to, from, subject and body information from the url. To use it, you just create an invisble web browser in the form, and then with a little string manipulation, you can navigate to the webbrowser with all the info necessary to send the email.

The page is on my site at www.startingqbasic.co.uk/aspmailer.asp.

To use it, add values for to=,from=,subject= and body= values to the url and there you go. I use this vb code:


VB Code:
  1. Private Sub sendmailbutton_Click()
  2. Dim mailurl As String
  3.  
  4. mailurl = "http://www.startingqbasic.co.uk/aspmailer.asp?"
  5. ' that line sets the start of the page string
  6.  
  7. mailurl = mailurl + "to=" + to_box.Text
  8. 'this adds the to details to the navigation string
  9.  
  10. mailurl = mailurl + "&" + "from=" + from_box.Text
  11. 'this adds the from details to the navigation string
  12.  
  13. mailurl = mailurl + "&" + "subject=" + subject_box.Text
  14. 'this adds the subject details to the navigation string
  15.  
  16. mailurl = mailurl + "&" + "body=" + body_box.Text
  17. 'this adds the subject details to the navigation string
  18.  
  19. mailbrowser.Navigate (mailurl)
  20. 'this navigates the webbrowser to the page
  21.  
  22. End Sub

And thats it. It's free, and if you would like the asp code for it, just email and ask.

KAZAR