Jump to content
xisto Community
Sign in to follow this  
connectpal

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

Recommended Posts

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.

Edited by microscopic^earthling (see edit history)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 :DI 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 :D

Share this post


Link to post
Share on other sites

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:

 

Imports System;Imports System.Web.Mail;Dim EmailTo As String     'Emailaddres for user to sendDim EmailFrom As String   'Emailaddres for user from Dim MailSubject As String 'Subject of MailDim MessageBody As String 'MessageDim ServerName As String  'Server Name - importantServerName = "<<Your SMTP server's Name>>"'Similarly, add in EmailTo, EmailFrom etc parameters hereEmailTo = "someone@recipient.net"EmailFrom = "me@mysqlf.net"........'Set the SMTP Server's addressSmtpMail.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 errorsTry	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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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://forums.xisto.com/no_longer_exists/;)=True .Item("http://forums.xisto.com/no_longer_exists/;) = 1 .Item("http://forums.xisto.com/no_longer_exists/;) = "yourmail@gmail.Com" .Item("http://forums.xisto.com/no_longer_exists/;) = "yourpassword" .Item("http://forums.xisto.com/no_longer_exists/;) = "smtp.Gmail.Com" .Item("http://forums.xisto.com/no_longer_exists/;) = 2 .Item("http://forums.xisto.com/no_longer_exists/;) = 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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
mailing code not work on serverHow To Send Email Using VB (using SMTP) ?I already used this code and it run very well on my pc but when I upload html page which having mailing vb script code, on server it didnt give any responce means mail is not send to mentioned email id.Pls give me solution for that I tryed it lot but no proper solution.-question by ranjeet

Share this post


Link to post
Share on other sites
Sending email from gmail - how to send mail from gmail using vb6How To Send Email Using VB (using SMTP) ?

Hi,

Is there any way to send mail from gmail using SMSP.

I used the code which u have provided but not able to send the mail.

getting error message as  

run time error

the transport failed to connect to the server.

please help me out

 

Thanks

Share this post


Link to post
Share on other sites
code executed but no mailsHow To Send Email Using VB (using SMTP) ?Replying to miCRoSCoPiC^eaRthLinGHi, I used your above code with ssl encryption. Code executed successfully but I didn't receive any mails to the mail id used in my code so far.Pl help me to solve this. Its urgent...Thanks in advance-question by sree

 

Share this post


Link to post
Share on other sites
how to over come "The transport failed to connect to the server."How To Send Email Using VB (using SMTP) ?

using CDO objects I have got this message

The transport failed to connect to the server.

can any one help me against this problem

-reply by Farrukh jamal

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.