Solved

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

Posted on 2004-04-09
9
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to implement Singleton Design Pattern in Java.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

632 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