Solved

e-mail ?

Posted on 1998-11-11
7
282 Views
Last Modified: 2013-11-13
Let say I have some information like :
name, age, phone#, address.
After the user entered all the information and pressed "ok" button, then all the information will send to an e-mail address. Is that possible to do that in VB ?
My professor said no.

If yes, could you teach me how .

Thank a lot
0
Comment
Question by:johnnhoj111198
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 2

Accepted Solution

by:
BergJC earned 200 total points
ID: 1444368
Here's some example code I have. See if it can help you out. You'll need to place a winsock control in your app.

Description:Allows sending of e-mail (SMTP) directly from
'     a VB app using Winsock, WITH OUT having to buy an expensive
'     add on component

//Input Requirements: Server Address (Name or IP), Senders & //Recipeient's Names, Sender & Recipient E-Mail address, Body of //message

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 worldcomputers.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


0
 

Author Comment

by:johnnhoj111198
ID: 1444369
what is winsock and where can I get it, mine is vb 4.0.
can you tell me how to use winsock, like how to install
0
 
LVL 1

Expert Comment

by:tjp
ID: 1444370
Do you plan to do this across a domain running Exchange, or is it something more like a dial-up connection to a SMTP server?

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 15

Expert Comment

by:ameba
ID: 1444371
Sender:
Can send e-mail with attached simple text-file.
Text file can be like this:
name: John
age: 25
phone: 1-11-111-111
address: SomeStreet 75, SomeCity 10000
-----------------
Receiver:
Files can be automaticaly downloaded to download directory, e.g. with Eudora
- so your program would watch this directory and see any "new" file,
Or, when email is manualy read, you can allow your users to drag and drop attachments on your application.
After reading and parsing this received small files, you can automatically save ~customer data, or prompt your user with form filled with data.
----------------
Let me know if you want any code, e.g. sending this txt attachments via Outlook Express.
0
 
LVL 2

Expert Comment

by:BergJC
ID: 1444372
I know the Winsock control ships with VB5 & VB6, but I've never had VB4. Does anyone else know where he can get the winsock control for VB4 32-bit (if he can at all)?
0
 
LVL 1

Expert Comment

by:tjp
ID: 1444373
I believe that we had to purchase such a control at a job i had way back when i used vb 4...  i know we had one for vb 3, and we upgraded it to an OCX when 4 came out.
0
 

Author Comment

by:johnnhoj111198
ID: 1444374
I have winsock.dll, can I use that ?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bunnyEars2 challenge 6 70
count7 challenge 12 70
recursion example 16 70
Programatically extract date from website 8 20
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now