Nov 21, 2009

How To Send Email Using VB (using SMTP) ? - best way to send email in vb

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Programming General > BASIC / Visual Basic (.NET)

How To Send Email Using VB (using SMTP) ? - best way to send email in vb

connectpal
Hi everybody,

I want to send an email to multi users through my VB application.
I don't know if I can use a VB class for this case or I should download a smtp mail component.
I would be thankful if you can suggest me the best solution.
Please give me a code example for former solution or introduce me an effective free, permanent component.

Comment/Reply (w/o sign-up)

IcedMetal
I , myself, am not sure about this. My friend says it can be done purely through VB. I will find out more about this from her. I have doubts about your legal purposes of this program you are going to make, but oh well, it's your choice.

Comment/Reply (w/o sign-up)

Spectre
I'm not a huge fan of Visual Basic, but controlling an SMTP server isn't all that hard. Basically, all you need to do is connect to it, specify the sender and receipient(s), and send the message.

And also, you might want to consider posting this in the Visual Basic forum.

Comment/Reply (w/o sign-up)

jipman
Using winsock is enough.

But you do need a SMTP server where you have a account from, like the smtp server of your isp since relaying is disabled in 99 out of 100 servers these days tongue.gif

I did create a small basic smtp email proggie though, if you need the VB source i might even mail it to you if you ask nicely wink.gif

Comment/Reply (w/o sign-up)

runefantasy
You can use the Microsoft Webbrowser control in there and use PHP smile.gif

Comment/Reply (w/o sign-up)

miCRoSCoPiC^eaRthLinG
I can provide you a solution using VB.NET - I can't stand VB6 anymore..

The .NET framework provides you with a class called SmtpMail - which under normal circumstances isn't available for use with Windows forms. It's meant for ASP.NET applications and can be found in the library System.Web.Mail namespace. All you've to do to make it work in your WinForm application is include a Reference to the file, System.Web.dll. This can be done by right-clicking on References in your Project explorer and clicking Add reference.

Once you've added this, use the following code to send mails out:

CODE
Imports System;
Imports System.Web.Mail;

Dim EmailTo As String     'Emailaddres for user to send
Dim EmailFrom As String   'Emailaddres for user from
Dim MailSubject As String 'Subject of Mail
Dim MessageBody As String 'Message
Dim ServerName As String  'Server Name - important


ServerName = "<<Your SMTP server's Name>>"
'Similarly, add in EmailTo, EmailFrom etc parameters here
EmailTo = "someone@recipient.net"
EmailFrom = "me@mysqlf.net"
...
.....


'Set the SMTP Server's address
SmtpMail.SmtpServer = ServerName


'This is the code that sends out the email based on whatever server information you've set
'Enclosed within Try-Catch block to catch exceptions in case of errors
Try
    SmtpMail.Send (EmailFrom, EmailTo, MailSubject, MessageBody)
Catch ex As Exception
   MsgBox ( "Delivery Failure: " & ex.Source & ex.Message )
End Try


Hope this helps...
Regards,
m^e

 

 

 


Comment/Reply (w/o sign-up)

FeedBacker
coding in email
How To Send Email Using VB (using SMTP) ?

I have to simple coding in email sending.I have use To,From,Subject, Message and Submit Button...When I send mail it will be store in my computer..I have use ASP.net with VB,VB.NET.

-reply by chitar bahadur

Comment/Reply (w/o sign-up)

FeedBacker
Replying to Feedbacker
Sub SendMail()
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.Microsoft.Com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.Microsoft.Com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.Microsoft.Com/cdo/configuration/sendusername") = "yourmail@gmail.Com"
.Item("http://schemas.Microsoft.Com/cdo/configuration/sendpassword") = "yourpassword"
.Item("http://schemas.Microsoft.Com/cdo/configuration/smtpserver") = "smtp.Gmail.Com"
.Item("http://schemas.Microsoft.Com/cdo/configuration/sendusing") = 2
.Item("http://schemas.Microsoft.Com/cdo/configuration/smtpserverport") = 25
.Update
End With

strbody = "Sample message " & Time

With iMsg
Set .Configuration = iConf
.To = sendto
.CC = ""
.BCC = ""
' Note: The reply address is not working if you use this Gmail example
' It will use your Gmail address automatic. But you can add this line
' to change the reply address .ReplyTo = "Reply@something.Com"
.From = "<mail to be displayed as @gmail.Com>"
.Subject = "subject"
.TextBody = strbody
.Send
End With

End Sub

-reply by shasunder

Comment/Reply (w/o sign-up)

FeedBacker
is it possible using MAPIMessages.
How To Send Email Using VB (using SMTP) ?

Hi All,



Is it possible to send mail with CC and BCC using MAPIMessages ?



Thanks in advance.



RK.

Comment/Reply (w/o sign-up)

(G)JOAO

Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.Microsoft.Com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.Microsoft.Com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.Microsoft.Com/cdo/configuration/sendusername") = "yourmail@gmail.Com"
.Item("http://schemas.Microsoft.Com/cdo/configuration/sendpassword") = "yourpassword"
.Item("http://schemas.Microsoft.Com/cdo/configuration/smtpserver") = "smtp.Gmail.Com"
.Item("http://schemas.Microsoft.Com/cdo/configuration/sendusing") = 2
.Item("http://schemas.Microsoft.Com/cdo/configuration/smtpserverport") = 25
.Update
End With

strbody = "Sample message " & Time

With iMsg
Set .Configuration = iConf
.To = sendto
.CC = ""
.BCC = ""
' Note: The reply address is not working if you use this Gmail example
' It will use your Gmail address automatic. But you can add this line
' to change the reply address .ReplyTo = "Reply@something.Com"
.From = "<mail to be displayed as @gmail.Com>"
.Subject = "subject"
.TextBody = strbody
.Send
End With

THEREis a error in the ".Send"

whatcan it be??

-reply by JOAO

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : Email Vb Smtp Email Vb


    Looking for send, email, vb, smtp, send, email, vb

See Also,

*SIMILAR VIDEOS*
Searching Video's for send, email, vb, smtp, send, email, vb
advertisement



How To Send Email Using VB (using SMTP) ? - best way to send email in vb

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com