A Programmers thoughts
How to send email using SMTP
Sending email using vb.net 2.0 framework is quite different from 1.1. The 1.1 framework is using a System.Web.Mail while 2.0 uses System.Net.Mail and it makes really different. There are some codes that are obsolete in 2.0 framework already that exist in 1.1 framework. In my case, since I am using vb.net 2.0 framework then I will share my code here that i used in my program that will send emails. I hope this will help to the people who are seeking codes that will send an email using vb.net 2.0 framework. As a default I am using gmail for my demo but it can be used to any email server as long as you know the configuration.
Set iMsg = CreateObject(“CDO.Message”)
Set iConf = CreateObject(“CDO.Configuration”)
Set Flds = iConf.Fields
schema = “http://schemas.microsoft.com/cdo/configuration/”
Flds.Item(schema & “sendusing”) = 2
Flds.Item(schema & “smtpserver”) = “smtp.gmail.com”
Flds.Item(schema & “smtpserverport”) = 465
Flds.Item(schema & “smtpauthenticate”) = 1
Flds.Item(schema & “sendusername”) = “myemail@gmail.com”
Flds.Item(schema & “sendpassword”) = “mypassword”
Flds.Item(schema & “smtpusessl”) = 1
Flds.Update
With iMsg
.To = “admin@uiccs07.net”
.From = “admin@uiccs07.net>”
.Sender = “uiccs07.net”
.ReplyTo = “admin@uiccs07.net”
.Subject = “This is a subject”
.HTMLBody = “This is sample html email.”
.Organization = “uiccs07.net”
Set .Configuration = iConf
SendEmailGmail = .Send
End With
set iMsg = nothing
set iConf = nothing
set Flds = nothing
| Print article | This entry was posted by shyguy on May 7, 2009 at 4:40 pm, and is filed under Vb.net Code and Snippets. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |











about 1 year ago
It is the coolest site,keep so!
about 1 year ago
Very nice site!