Solved

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

Posted on 2004-04-09
9
297 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
Comment Utility
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
Comment Utility
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
Comment Utility
Like I said, you simply need to add the DATA before the Mail Body.



-Brian
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 19

Expert Comment

by:BrianGEFF719
Comment Utility
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
Comment Utility
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
Comment Utility
>> 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
Comment Utility
PAQed - no points refunded (of 50)

modulo
Community Support Moderator
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

763 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

9 Experts available now in Live!

Get 1:1 Help Now