Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-09
9
Medium Priority
?
308 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

719 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