Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

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

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
Alexius71
Asked:
Alexius71
1 Solution
 
BrianGEFF719Commented:
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
 
zzzzzoocCommented:
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
 
BrianGEFF719Commented:
Like I said, you simply need to add the DATA before the Mail Body.



-Brian
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
BrianGEFF719Commented:
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
 
Alexius71Author Commented:
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
 
zzzzzoocCommented:
>> 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
 
moduloCommented:
PAQed - no points refunded (of 50)

modulo
Community Support Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now