Important alert: (current site time 7/16/2013 4:15:57 AM EDT)
 

VB icon

SMTP: Simple Mail Testing Program

Email
Submitted on: 4/17/1999
By: Brian Anderson  
Level: Not Given
User Rating: By 3 Users
Compatibility: VB 5.0, VB 6.0
Views: 60588
 
     Allows sending of e-mail (SMTP) directly from a VB app using Winsock, WITH OUT having to buy an expensive add on componet
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :SMTP: Simple Mail Testing Program
'**************************************
None		
		
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: SMTP: Simple Mail Testing Program
' Description:Allows sending of e-mail (SMTP) directly from a VB app using Winsock, WITH OUT having to buy an expensive add on componet
' By: Brian Anderson
'
' Inputs:Requires: Server Address (Name or IP), Senders & Recipeient's Names, Sender & Recipient E-Mail address, Body of message
'
' Returns:Nothing really, does give status on sending operation
'
' Assumes:Very straight forward. Makes sending mail from a VB program EASY!
'
' Side Effects:NONE!
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=841&lngWId=1'for details.'**************************************

Dim Response As String, Reply As Integer, DateNow As String
Dim first As String, Second As String, Third As String
Dim Fourth As String, Fifth As String, Sixth As String
Dim Seventh As String, Eighth As String
Dim Start As Single, Tmr As Single
Sub SendEmail(MailServerName As String, FromName As String, FromEmailAddress As String, ToName As String, ToEmailAddress As String, EmailSubject As String, EmailBodyOfMessage As String)
 
 Winsock1.LocalPort = 0 ' Must set local port to 0 (Zero) or you can only send 1 e-mail per program start
 
If Winsock1.State = sckClosed Then ' Check to see if socet is closed
 DateNow = Format(Date, "Ddd") & ", " & Format(Date, "dd Mmm YYYY") & " " & Format(Time, "hh:mm:ss") & "" & " -0600"
 first = "mail from:" + Chr(32) + FromEmailAddress + vbCrLf ' Get who's sending E-Mail address
 Second = "rcpt to:" + Chr(32) + ToEmailAddress + vbCrLf ' Get who mail is going to
 Third = "Date:" + Chr(32) + DateNow + vbCrLf ' Date when being sent
 Fourth = "From:" + Chr(32) + FromName + vbCrLf ' Who's Sending
 Fifth = "To:" + Chr(32) + ToNametxt + vbCrLf ' Who it going to
 Sixth = "Subject:" + Chr(32) + EmailSubject + vbCrLf ' Subject of E-Mail
 Seventh = EmailBodyOfMessage + vbCrLf ' E-mail message body
 Ninth = "X-Mailer: EBT Reporter v 2.x" + vbCrLf ' What program sent the e-mail, customize this
 Eighth = Fourth + Third + Ninth + Fifth + Sixth ' Combine for proper SMTP sending
 Winsock1.Protocol = sckTCPProtocol ' Set protocol for sending
 Winsock1.RemoteHost = MailServerName ' Set the server address
 Winsock1.RemotePort = 25 ' Set the SMTP Port
 Winsock1.Connect ' Start connection
 
 WaitFor ("220")
 
 StatusTxt.Caption = "Connecting...."
 StatusTxt.Refresh
 
 Winsock1.SendData ("HELO yourdomain.com" + vbCrLf)
 WaitFor ("250")
 StatusTxt.Caption = "Connected"
 StatusTxt.Refresh
 Winsock1.SendData (first)
 StatusTxt.Caption = "Sending Message"
 StatusTxt.Refresh
 WaitFor ("250")
 Winsock1.SendData (Second)
 WaitFor ("250")
 Winsock1.SendData ("data" + vbCrLf)
 
 WaitFor ("354")
 Winsock1.SendData (Eighth + vbCrLf)
 Winsock1.SendData (Seventh + vbCrLf)
 Winsock1.SendData ("." + vbCrLf)
 WaitFor ("250")
 Winsock1.SendData ("quit" + vbCrLf)
 
 StatusTxt.Caption = "Disconnecting"
 StatusTxt.Refresh
 WaitFor ("221")
 Winsock1.Close
Else
 MsgBox (Str(Winsock1.State))
End If
 
End Sub
Sub WaitFor(ResponseCode As String)
 Start = Timer ' Time event so won't get stuck in loop
 While Len(Response) = 0
Tmr = Start - Timer
DoEvents ' Let System keep checking for incoming response **IMPORTANT**
If Tmr > 50 Then ' Time in seconds to wait
 MsgBox "SMTP service error, timed out while waiting for response", 64, MsgTitle
 Exit Sub
End If
 Wend
 While Left(Response, 3) <> ResponseCode
DoEvents
If Tmr > 50 Then
 MsgBox "SMTP service error, impromper response code. Code should have been: " + ResponseCode + " Code recieved: " + Response, 64, MsgTitle
 Exit Sub
End If
 Wend
Response = "" ' Sent response code to blank **IMPORTANT**
End Sub
Private Sub Command1_Click()
 SendEmail txtEmailServer.Text, txtFromName.Text, txtFromEmailAddress.Text, txtToEmailAddress.Text, txtToEmailAddress.Text, txtEmailSubject.Text, txtEmailBodyOfMessage.Text
 'MsgBox ("Mail Sent")
 StatusTxt.Caption = "Mail Sent"
 StatusTxt.Refresh
 Beep
 
 Close
End Sub
Private Sub Command2_Click()
 
 End
 
End Sub
Private Sub Form_Load()
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
 Winsock1.GetData Response ' Check for incoming response *IMPORTANT*
End Sub


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
4/12/1999 12:11:00 PMRodrigo Calvo

how could I detect automatically which is the SMTP mail server?
so that don't my clients have to make him manually?
(If this comment was disrespectful, please report it.)

 
4/12/1999 12:13:00 PMRodrigo Calvo

how do I detect the mailservername in automatic form?
(If this comment was disrespectful, please report it.)

 
4/12/1999 2:11:00 PMPatrick Clochesy

Rod-

The mailserver cant be detected easily. Usually it differs for whatever isp they use. You *could* find an open one and send it from there. (the server has to have relaying turned on.)
(If this comment was disrespectful, please report it.)

 
4/12/1999 6:11:00 PMmark

any ideas on how to send an attachment?

(If this comment was disrespectful, please report it.)

 
4/13/1999 11:25:00 PMchris

Would anyone happen to know where I can find some help on Winsock in VB5/6
(If this comment was disrespectful, please report it.)

 
4/15/1999 10:32:00 PMpaul sturridge

send me a copy of email source code,please.
(If this comment was disrespectful, please report it.)

 
4/18/1999 1:29:00 PMRaouf El-Messiry

This is what I really was looking for for a very long time.
Thank you.

Just one question:
Written here that this code is submitted Apr 17, 99
and is accessed 11825 times, how ??? :)
(If this comment was disrespectful, please report it.)

 
4/19/1999 5:55:00 AMDave

I would like to know how to send an attachment also
(If this comment was disrespectful, please report it.)

 
4/19/1999 6:57:00 AMWayne Muzzy

I get a "runtime error 10036, a blocking winsock operation is in progress". What did I do wrong?
(If this comment was disrespectful, please report it.)

 
4/19/1999 8:30:00 AMAshraful Alam

How can I send UNICODE(true type font) using winsock control.
thanks
Ashraful
(If this comment was disrespectful, please report it.)

 
4/21/1999 4:52:00 PMMjrVodka

is there a good way to find out the mail server's name/ip? the only thing ive seen done is using a big db and searching with the @whatever.com (commercial mailers seem to use this too)
(If this comment was disrespectful, please report it.)

 
4/21/1999 6:29:00 PMVB user

Can I make this send the results of a form that people fill out so I can get feedback on my program? I'm desperate! Help me!
(If this comment was disrespectful, please report it.)

 
4/23/1999 3:27:00 PMDimitri Campana

How to send an attachment? Is possible?
Thanks.

(If this comment was disrespectful, please report it.)

 
5/1/1999 3:48:00 AMccjx

please send me an example of the same thing and include the code to send an attachment
(If this comment was disrespectful, please report it.)

 
5/2/1999 3:03:00 PMRoderick Thompson

An excellent program however a couple of errors were observed.
In the Sub WaitFor there is a problem with the timings. In the line Tmr = Start - Timer, this will always produce a negative value since Timer will always be the greater value. Change this line to Tmr = Timer - Start.

In addition add the line Tmr = Timer - Start below the line "While Left(Response, 3) <> ResponseCode"


(If this comment was disrespectful, please report it.)

 
5/4/1999 11:08:00 PMMichael Lau

Do we have something in reverse, i.e., getting e-mail (POP3) codes available somewhere anyone?

Thanks
(If this comment was disrespectful, please report it.)

 
5/14/1999 10:13:00 AMRobert

Seem to have problems with could you possible send me a VB file with the code running.
Thanks
(If this comment was disrespectful, please report it.)

 
5/16/1999 9:57:00 PMruss

could you please mail me the
forms or something, I cant get this to work!!! =(
(If this comment was disrespectful, please report it.)

 
5/17/1999 8:03:00 AMGerardo Larios Higuera

Could you please mail me the forms,or
the project, I cant get this to work.
Thanks.
(If this comment was disrespectful, please report it.)

 
5/17/1999 10:07:00 AMPapaioannou George

How can I send an attachment using that mail with Winsock ?

(If this comment was disrespectful, please report it.)

 
5/24/1999 2:21:00 PMJonathan

i need the ocx that offers winsock1 used in the code
(If this comment was disrespectful, please report it.)

 
5/24/1999 3:06:00 PMineedhelpineedhelpineedhelp

it says i don't have a licence to use winsock control help me!!!
(If this comment was disrespectful, please report it.)

 
5/25/1999 7:24:00 AMvenkateswara prasad

it is good. it helped me a lot.
thank you
(If this comment was disrespectful, please report it.)

 
5/25/1999 8:37:00 AMaa

aa
(If this comment was disrespectful, please report it.)

 
5/27/1999 9:54:00 AMOP

I've been looking for way to send an attachment with winsock EMail program like this, but no luck...Could somebody help, please.Thanks!
(If this comment was disrespectful, please report it.)

 
6/1/1999 5:09:00 PMJason

This is awsomw! Thanks loads for putting it out here...This makes life easy....
(If this comment was disrespectful, please report it.)

 
6/2/1999 9:45:00 AMEnigMaster

i got an error in the sendmail sub
Winsock1.LocalPort = 0 this will now work says object required ??? anyhelp with this?????

(If this comment was disrespectful, please report it.)

 
6/4/1999 4:53:00 AMMeghashyam

How can I send attachments through SMTP
How to use POP3

(If this comment was disrespectful, please report it.)

 
6/5/1999 9:07:00 PMJames Baker

Works well. You need to add the Winsock component and a few objects, but otherwise it's pretty easy.
(If this comment was disrespectful, please report it.)

 
6/11/1999 9:20:00 PMFreakboY

where can i get that ocx?
do u have it pliz send it to me pliz
thanx
(If this comment was disrespectful, please report it.)

 
6/12/1999 5:49:00 PMJason

I think the code is great, easy to use (to most) and effective. The only thing that is missing is a BCC (Blind Carbon Copy). If any of you know the code to add it, please email me: Mastersoft@email.com.

Thanks
(If this comment was disrespectful, please report it.)

 
6/14/1999 10:06:00 AMFlash

HOW DO i GET THIS THING TO WORK???
IT SAY AN ERROR IN THIS LINE :SendEmail txtEmailServer.Text, txtFromName.Text, txtFromEmailAddress.Text, txtToEmailAddress.Text, txtToEmailAddress.Text, txtEmailSubject.Text, txtEmailBodyOfMessage.Text

Any IDEa on how to fix it?

(If this comment was disrespectful, please report it.)

 
6/16/1999 6:59:00 AMReBeL16th

it says 'sending message' but nothing happens.
(If this comment was disrespectful, please report it.)

 
6/17/1999 10:02:00 AMRyan Huettner

ATTACHMENTS. Need to do 'em. SMTP. Right now would be great. Thanks.
(If this comment was disrespectful, please report it.)

 
6/18/1999 11:02:00 AMEnmanuel Genovés

I would like to know how to send an attachment also in this Smtp sample
(If this comment was disrespectful, please report it.)

 
6/22/1999 5:00:00 AMDISEASE_2000

Hmmm... you guy shouldn't post msg and say "Why this thing doesn't work?" Well... if it doesn't work, then figure it out yourself, that's the only way you will learn. And I think this code will work, because if it won't, then why he post it here? so there's must be a way of making it work. ;) What come inside you is always right! ---->



"Why doens't it work?" "Why doesn't this thing work?" "I got an error!!" "Can you send me the Project file pliz?" Man, all those comment, aren't they annoying to you?
(If this comment was disrespectful, please report it.)

 
6/22/1999 4:24:00 PMSomu

Excellent Code.

Can anyone HELP Me.
How to send attachments using this?
And message as HTML?

Thanks
Somu
(If this comment was disrespectful, please report it.)

 
6/23/1999 5:00:00 PME T

Cuold you send me the whole thing, project and all?
(If this comment was disrespectful, please report it.)

 
6/24/1999 10:30:00 AMJay Otaku

im having some problems. there is an error with " Winsock1.LocalPort = 0 ' Must set local port to 0 (Zero) or you can only send 1 e-mail per program start" also how do you know what your mail server is?
(If this comment was disrespectful, please report it.)

 
7/1/1999 2:07:00 AMTim

It would be very good if somebody says me how to send username and password to the server, which requires an authorisation...
(If this comment was disrespectful, please report it.)

 
7/2/1999 12:09:00 PMYellow Snow

I have gotten it to mail to netzero address but it will not mail to Aol and Hotmail address. I am thinking that the mail servers are to complex or something.
(If this comment was disrespectful, please report it.)

 
7/4/1999 4:08:00 AMPierrick

A very good tip!!!!
(If this comment was disrespectful, please report it.)

 
7/5/1999 7:16:00 AMLeigh

ATTACHMENTS??? Fantastic program, but everyone wants to now how to attach files. I think you do it during the 'DATA' phase, but I don't know how. Even just how to do it during a telnet session (which is effectivly what this program does).

THANKYOU.
(If this comment was disrespectful, please report it.)

 
7/5/1999 10:58:00 PMHyrax

Wow, i hope this is an eyeopener, If you guys get errors, it is most likely a typo, or you fergot to actually look at the code. Try doin that sometime. It may help you shut-up.
(If this comment was disrespectful, please report it.)

 
7/5/1999 11:08:00 PMBrian Anderson

I have recieved VERY MANY emails regarding email Attachments, and would like to say, that the code for this i am keeping very private, many others know, so you can get it off them. The winsck.ocx can be found at many Department Stores nation-wide.
(If this comment was disrespectful, please report it.)

 
7/19/1999 10:39:00 AMblah

can anyone give me a list of mail servers that i can use with this code? if so please mail me
(If this comment was disrespectful, please report it.)

 
7/21/1999 3:57:00 AMMarkus

How to send an attachments
(If this comment was disrespectful, please report it.)

 
7/26/1999 1:16:00 PMGe]\/[ini

I need to know how or where to find how to send attachments.

Oh yeah, and all you people asking why it doesn't work:

YOU HAVE TO CREATE THE OBJECT IF YOU GET AN OBJECT REQUIRED ERROR. If the program looks for txtEmailFrom.text and txtEmailFrom dont exist then OF COURSE you'll get an error.

jeez...
(If this comment was disrespectful, please report it.)

 
8/3/1999 9:26:00 PMJulio

I would like to know how to send an attachment...

Please!
(If this comment was disrespectful, please report it.)

 
8/6/1999 9:19:00 AMFrancisco Cruz

Muy buen programa heee!! a mi me va ha ahorar trabajo y tiempo porque desde hace tiempo quise hacer esto ,, thank you!!


(If this comment was disrespectful, please report it.)

 
8/15/1999 11:56:00 AMHernán Chiapella

Felicitaciones y muchas gracias, me es muy útil.
(If this comment was disrespectful, please report it.)

 
8/16/1999 11:32:00 PMNovaCode

Listen up everyone!
IT DOES WORK SO STOP BAGGING BRIAN!
Brian is an absolute legend for releasing that code, and all you do is post dumb remarks. Why don't you lamers look at the code yourselves and think why its not working.

You need a Winsock control on your form or you'll get the error - object doesn't exist or something.
You need all the text boxes with the correct names on them (txtEmailServer, txtFromName, etc)
And for the server (domain name) you must put in your POPMAIL server. e.g. Mail.Telstanet.com.au
tmr = start - timer should really be tmr = timer - start


There, now stop harrasing Brian and work it out!
(If this comment was disrespectful, please report it.)

 
8/18/1999 11:58:00 AMp0_b0y

This is an awesome code. You other people need to get a life.
(If this comment was disrespectful, please report it.)

 
8/23/1999 6:21:00 PMCentaurus

The code works. AND for all of you saying how BAD this code is, it was probably not meant to be a stand alone. Just a good example of using winsock to send text to you.

If you cant figure out where to find the port, then you are in trouble :)
(If this comment was disrespectful, please report it.)

 
8/29/1999 12:07:00 PMspacecow

send me the complete source code please...thank you very much
(If this comment was disrespectful, please report it.)

 
8/29/1999 5:07:00 PMMatt Anderson

The code is good, in that it works, but a better way to do it is instead of using the WaitFor function, which forces a waiting period that might be much larger than the time it takes for the server to respond. A better way to do it would be to place most of the interaction code in the Winsock1_DataArrival event, where it would decide the next action to take and promptly reply.

Also for everyone who is asking about sending attachments, this is done by adding something like this to the header (this may not be exactly correct b/c I am doing this from memory),
to:abc
from:def
subject: subject line...
content-type: multipart/attachment border = "========123abc"

========123abc content-type: text/plain


Anyone interested in purchasing a compiled SMTP or POP3 .ocx control for a small price, chech out http://www.homeworkfinder.com/personal/matt, a sample program is included
(If this comment was disrespectful, please report it.)

 
9/5/1999 2:59:00 AMKing Patrik

There's help for both run-time errors and the Winsock control itself. Press F1 to get help, it's not simpler than that!
(If this comment was disrespectful, please report it.)

 
9/9/1999 7:11:00 AMMe

Yes, this can send attachments, but you have to encode the attachment file using a compliant uuencode protocol. If it took you more than 5 minutes to get the above code working, then don't even bother trying to write it yourself. Otherwise, the algorithms are posted all over the web and usenet. There's a lotta math involved.
(If this comment was disrespectful, please report it.)

 
9/9/1999 7:42:00 AMNicolas Buschittari

Help me !! i need send a attachment, Thanks
(If this comment was disrespectful, please report it.)

 
9/9/1999 10:25:00 AMRasCA* Com

This thing is great, GREAT.
I can promiss you that I've searched a lot for this thing...

Thank you.
(If this comment was disrespectful, please report it.)

 
9/9/1999 6:14:00 PMSteve Langdon

ATTENTION!
All you guys that are crying "It doesn,t work", "Send me the project" &
blah,blah blah.
If you want to be a "PROGRAMMER" then this
should be your 1st lesson!
NO PAIN, NO GAIN!

If you are that lazy then maybe you should go into sales or something. YOU don't have what it takes!
There is nothing wrong with being new and having questions, but programming is a lot more than Cut,Paste & Run.

Lesson 2. Tear it apart and see what makes it tick!

Thanks for your time and I will now step down from my soapbox!


(If this comment was disrespectful, please report it.)

 
9/10/1999 11:51:00 AMChuck

I'll take Brians original code and convert it for use with an ActiveX DLL.

Should I repost it when I'm done?
(If this comment was disrespectful, please report it.)

 
9/11/1999 2:06:00 PM0-C-O-O-L

Just wondering could you tell me is there anyway that i could create a program that would connect to the internet automaticly and send a E-Mail automaticly with out the user having to do anythink.
(If this comment was disrespectful, please report it.)

 
9/14/1999 8:41:00 AM-Rockin-

The only way to learn it by example, and you need to give a project. Also, you need attachment code, or else your program is worthless like all the Microsoft apps.
(If this comment was disrespectful, please report it.)

 
9/15/1999 5:30:00 AMLiron Golan

This didn't help me, the code didn't work on my application
(If this comment was disrespectful, please report it.)

 
9/15/1999 10:58:00 AMMailGuy

#1 SMTP does not support attachements, so give it up, losers.
#2 This code replaces the function I purchased IP works for.
So if you can't get it running, go buy IP*works, and stop bugging
the man for more source!

(If this comment was disrespectful, please report it.)

 
9/22/1999 8:36:00 AMRyan

what is winsock?
do i need a seperate program to run this?
(If this comment was disrespectful, please report it.)

 
9/23/1999 4:59:00 PMNoName NoGame

Does it work?
(If this comment was disrespectful, please report it.)

 
9/29/1999 7:32:00 AMRay

Awesome Code - you can't convert it to an Active DLL since it uses a Component, right?
(If this comment was disrespectful, please report it.)

 
9/29/1999 9:57:00 PMBrandon

Just one question. If I need to send a mail to more than one receipient, what should be the format/protocol 'ToEMailAddress' and 'ToNameTxt' variables? Need this answer quite urgently. Appreciate your help.
(If this comment was disrespectful, please report it.)

 
10/10/1999 3:00:00 AMCarBoX

mail.compuserve.com <--- WORKS GREAT!
(If this comment was disrespectful, please report it.)

 
10/19/1999 6:45:00 PMcruzerz

I have implemented this code in my FREE program. Also made the code work better.
http://codearchive.yi.org/exploit/
has source code avail too!

(If this comment was disrespectful, please report it.)

 
10/27/1999 12:22:00 AMgnilow

if I use mail.hotmail.com as the server,
I can only send mails to hotmail accounts? how do I send to others?
(If this comment was disrespectful, please report it.)

 
11/3/1999 12:24:00 PMjoris beckers

My winsock doen't work.
please help!!!

(If this comment was disrespectful, please report it.)

 
11/14/1999 9:06:00 PMPhrostbyte Software

nice

Yes it's possable to add attachments Attachements need to be send part by part in packets. Packetsize is the amount of 8-bit (ascii) charters can be sent in one shot.

And isn't the mail server the @whatever.com part of a e-mail? Like if my e-mail was bobdole@usa.net, usa.net should be the mail server
(If this comment was disrespectful, please report it.)

 
11/17/1999 2:57:00 PMDarryl Anderson

Absolutely Brilliant, works like a charm.

Thanks very much.
(If this comment was disrespectful, please report it.)

 
12/18/1999 4:30:58 AMND

Excellent


(If this comment was disrespectful, please report it.)

 
1/26/2000 1:42:02 PMafraz

I got error problem in command1_click
kindly send me form1 only
Also how do i send pics
regards

(If this comment was disrespectful, please report it.)

 
1/31/2000 2:07:49 AMrichard

Hi Brian,

thanks for this real eye-opener, great work man!

I have a small problem : See, the code
you provided works with a form and a command button when clicked. I am hoping to build it as a sub that can run
as soimething like Sub main(). Thing is I have included the Winsock control component in my project already and i can comopile it into .exe but when run, the winsock.Localport line gives me an error.
I am new at this but i do not intend to plagarise your code, Brian. I need your suggestions (and the rest of U VB experts out there) as to how i can adapt this into straight VB code wihtout the use of forms/buttons and then just use it as a sub in itself.

once again, thanks. hope to hear from you soon.

best regards, richard.
(If this comment was disrespectful, please report it.)

 
2/2/2000 7:09:45 PMafraz

Hey man, I am having problem Command1_Click()
the error says agruement not optional ...can u fix it or not...
Still waiting for an answer!!!!!!!!!!!!
regards
(If this comment was disrespectful, please report it.)

 
2/2/2000 7:43:51 PMafraz

Hey, man. I fixed bug....StatusTxt instead of label1.

Hey, man....it is WORKING now.

Hey, man.......Thank you..

Hey man...I din't abuse you...keep ur work and i need how
to send pics by using richtextbox..it
could be rtf or seltext or selrtf.
Brian, Good work..
(If this comment was disrespectful, please report it.)

 
2/8/2000 1:36:33 AMShiau Chen

Here is my piece of code

Sub SendMail()
Dim Winsock1 As Winsock

With Winsock1
.Protocol = sckTCPProtocol
.RemoteHost = "csam.com.my"
.RemotePort = 21
.Connect
End With

The problem is when I debug, when it comes to .protocol there will be an erro msg saying that Runtime error 91, Object variable or with block variable not set.

Has tried using Set instead of using With but still the same. Pls help. Thank you

End Sub


(If this comment was disrespectful, please report it.)

 
3/21/2001 7:45:03 AMTrey Smith

First off EXCELLENT CODE!
You have a very firm grasp of SMTP. Your class... well it's horrible, but the code works so well, I'm going to go the distance and re-structure it. Ok everyone who's having problems. His code uses an older object creation meathod, so you have to do a little trick. Create a form1. Create a winsock control on it copy paste it onto the form. It will ask if you wish to make a control array emement. Say YES. Now delete the second instance. This is done so his class can create more winsock controls. Then try this
With clsHerb
.Attach Form1
end with
that will bind the form to his class.
oh.. Shiau Chen, you forgot to do the new statement. Example:
dim a as clsHerb set a= new clsHerb
That should do it. I'll have a new version of the class submitted to Herb hopefully later this week, I'll add what features I can to make it simpler for you whom are struggling. You can also reach me at tsmith@impgraphics.com

-Trey
(If this comment was disrespectful, please report it.)

 
5/2/2002 8:19:53 AMJaspreet

please specify the code for how ro Speicify MIME type from winsock control in vb
(If this comment was disrespectful, please report it.)

 
1/3/2003 4:35:38 PM

Why does everyone think this code is so great? There are already example programs on PlanetSourceCode that already does pretty much this very same thing. I mean, anyone can take this code and make a few changes to it and post it on this site.... BIG DEAL.

Brian claims that he is keeping the code for the mail attachments very private. He acts like it is some piece of state of the art software but you can search the internet and find all sorts of info. I would bet that he doesn't even know how to do it.
(If this comment was disrespectful, please report it.)

 
11/22/2003 11:09:34 AMAndy Wells

Great code. I'm just having one problem with
(If this comment was disrespectful, please report it.)

 
11/22/2003 11:12:16 AMAndy Wells

ok, didn't seem to send the whole message last time so let's try again. I don't totally understand what "Winsock1.SendData ("HELO yourdomain.com" + vbCrLf)" is about. The mail server returns "500 Unknown command" even when i put in my mail server's name, and what does "HELO" mean?
(If this comment was disrespectful, please report it.)

 
8/12/2004 1:09:14 PM

You really need to read the RFC for SMTP
(If this comment was disrespectful, please report it.)

 
4/4/2006 3:21:52 PMHardStream Software Development

This actually works!! There are many examples on how to send e-mails using Winsock, but almost none of them really work.. Tnx 4 uploading :D
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.