Solved

Winsock using....mail sending...mail receiving

Posted on 2004-04-09
9
300 Views
Last Modified: 2013-11-13
This is not a very Visual Basic Problem but i'm using it so...
This is the source code that i have implemented:

Winsock1.Connect "mail.server.it", 25
Delay (1)
Winsock1.SendData "helo" & vbCrLf
Delay (1)
Winsock1.SendData "MAIL FROM:<name@name.it>" & vbCrLf
Delay (1)
Winsock1.SendData "RCPT TO:<name1@name.it>" & vbCrLf
Delay (1)
Winsock1.SendData "DATA " & vbCrLf
Delay (1)
Winsock1.SendData "From: name@name.1" & vbCrLf
Delay (1)
Winsock1.SendData "To: name1@name.it" & vbCrLf
Delay (1)
Winsock1.SendData "Subject: Mail test" & vbCrLf
Delay (1)
Winsock1.SendData "Hello!!!" & vbCrLf
Delay (1)
Winsock1.SendData "." & vbCrLf
Delay (2)
Winsock1.Close

Where Winsock1 is a Winsock control and Delay is a Private Sub that do an n seconds delay.
All of this works fine, the problem is when i open Outlook Express and receive the mail i can see the sender, the subject but Outlook don't write anything in the body of the mail.
The text "Hello!!!" is considered as a property of the mail and not as the body of the mail.
What am i missing?

0
Comment
Question by:Alexius71
9 Comments
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10794971
Try this:



Winsock1.Connect "mail.server.it", 25
Delay (1)
Winsock1.SendData "helo" & vbCrLf
Delay (1)
Winsock1.SendData "MAIL FROM:<name@name.it>" & vbCrLf
Delay (1)
Winsock1.SendData "RCPT TO:<name1@name.it>" & vbCrLf
Delay (1)
Winsock1.SendData "DATA " & vbCrLf
Delay (1)
Winsock1.SendData "From: name@name.1" & vbCrLf
Delay (1)
Winsock1.SendData "To: name1@name.it" & vbCrLf
Delay (1)
Winsock1.SendData "Subject: Mail test" & vbCrLf
Delay (1)
Winsock1.Senddata "Data" & vbcrlf
Delay (1)
Winsock1.SendData "Hello!!!" & vbCrLf
Delay (1)
Winsock1.SendData "." & vbCrLf
Delay (2)
Winsock1.Close
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10795157
You should review the RFCs for the protocol:
http://www.networksorcery.com/enp/protocol/smtp.htm

Additionally, it goes somewhat like this..

helo(crlf)
mail from(crlf)
rcpt to(crlf)
data(crlf)
subject (lf)
message (lf)
message (lf)
message etc.. (lf)
. (crlf)
quit (crlf)

You shouldn't need the additional "From" and "To". Also, after "data" (for your message body), it's required to start using vbLf instead of vbCrLf for each line until "." (for quitting). So up to "data", it's vbCrlf and starting from "." again, it's vbCrlf again. vbLf for everything inbetween. I don't have a mail server to test on so pardon the confusing explanation.
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10799181
Like I said, you simply need to add the DATA before the Mail Body.



-Brian
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10799183
Try maybe like this:



Winsock1.Connect "mail.server.it", 25
Delay (1)
Winsock1.SendData "helo" & vbCrLf
Delay (1)
Winsock1.SendData "MAIL FROM:<name@name.it>" & vbCrLf
Delay (1)
Winsock1.SendData "RCPT TO:<name1@name.it>" & vbCrLf
Delay (1)
Winsock1.SendData "From: name@name.1" & vbCrLf
Delay (1)
Winsock1.SendData "To: name1@name.it" & vbCrLf
Delay (1)
Winsock1.SendData "Subject: Mail test" & vbCrLf
Delay (1)
Winsock1.Senddata "Data" & vbcrlf
Delay (1)
Winsock1.SendData "Hello!!!" & vbCrLf
Delay (1)
Winsock1.SendData "." & vbCrLf
Delay (2)
Winsock1.Close
0
 

Author Comment

by:Alexius71
ID: 10801119
I've solved the problem.
After the information about "Subject:...", "Date:...." "From:...","To:...." the Smtp protocol wait for a null line (Winsock.SendData VbLf), and then it consider all the characters after the message body. Just This!!!
Bye.
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 11424752
>> the Smtp protocol wait for a null line (Winsock.SendData VbLf), and then it consider all the characters after the message
>> body

That's actually a Line Feed character which I mentioned you having to use in my comment.

To refresh your memory --> [after "data" (for your message body), it's required to start using vbLf instead of vbCrLf]

--------
Rec.: Accept & PAQ / No Refund & PAQ

0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11441400
PAQed - no points refunded (of 50)

modulo
Community Support Moderator
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA : retain and exclude values based on a config sheet and multiple parameters 5 60
VBA filters 2 58
How to Add / Edit Windows Menu 4 59
RUNRMTCMD from AS/400 12 43
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 …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

816 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