473,671 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Email Sockets Question

I am building a simple smtp server to receive email as follows:
Private Sub Listen()
Dim Listener As New TcpListener("25 ")
Dim sb As New SocketAndBuffer ()
Listening = True
Listener.Start( )
Do Until Listening = False

sb.Socket = Listener.Accept Socket()
sb.Socket.Begin Receive(sb.Buff er, 0, sb.Buffer.Lengt h, 0,
AddressOf ReceiveCallBack , sb)
Loop
End Sub

Private Sub ReceiveCallBack (ByVal ar As IAsyncResult)
Dim sb As SocketAndBuffer = CType(ar.AsyncS tate,
SocketAndBuffer )
Dim numbytes As Int32 = sb.Socket.EndRe ceive(ar)

Dim Receive As String = ASCII.GetString (sb.Buffer, 0, numbytes)
_count += 1

If _count = 1 Then sb.Socket.Send( "220 smtp.example.co m SMTP
server ready"*** this initial is the part I cannot figure out***)

MsgBox("receive " + Receive)
sb.Socket.Send( sb.Buffer)
Array.Clear(sb. Buffer, 0, sb.Buffer.Lengt h)
sb.Socket.Begin Receive(sb.Buff er, 0, sb.Buffer.Lengt h, 0,
AddressOf ReceiveCallBack , sb)

End Sub

I am able to telnet into my server and echo text but the server is not
able to send data to the client.
Any help is appreciated. TIA

Dec 5 '06 #1
1 1337
Dim sr As New StreamReader(ns )
Dim returnedData As String = "220 smtp.sample.com SMTP
server ready"
Dim sw As New StreamWriter(ns )
sw.WriteLine(re turnedData)

iMaiden wrote:
I am building a simple smtp server to receive email as follows:
Private Sub Listen()
Dim Listener As New TcpListener("25 ")
Dim sb As New SocketAndBuffer ()
Listening = True
Listener.Start( )
Do Until Listening = False

sb.Socket = Listener.Accept Socket()
sb.Socket.Begin Receive(sb.Buff er, 0, sb.Buffer.Lengt h, 0,
AddressOf ReceiveCallBack , sb)
Loop
End Sub

Private Sub ReceiveCallBack (ByVal ar As IAsyncResult)
Dim sb As SocketAndBuffer = CType(ar.AsyncS tate,
SocketAndBuffer )
Dim numbytes As Int32 = sb.Socket.EndRe ceive(ar)

Dim Receive As String = ASCII.GetString (sb.Buffer, 0, numbytes)
_count += 1

If _count = 1 Then sb.Socket.Send( "220 smtp.example.co m SMTP
server ready"*** this initial is the part I cannot figure out***)

MsgBox("receive " + Receive)
sb.Socket.Send( sb.Buffer)
Array.Clear(sb. Buffer, 0, sb.Buffer.Lengt h)
sb.Socket.Begin Receive(sb.Buff er, 0, sb.Buffer.Lengt h, 0,
AddressOf ReceiveCallBack , sb)

End Sub

I am able to telnet into my server and echo text but the server is not
able to send data to the client.
Any help is appreciated. TIA
Dec 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1820
by: Madestro | last post by:
Hi guys, I am making a small program to retrieve e-mails from POP accounts. I got all the e-mail parsing stuff figured out, but I cannot seem to come up with a way to find out which e-mails are NEW so I don't have to retrieve them all. If you have experience with this kind of thing, you know that the server creates unique IDs for all the messages, but this IDs are not guaranteed to be unique, since they can be reused once a message is...
4
2161
by: 0to60 | last post by:
I have a question about socket programming in general. Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I create a socket, bind it to a port, put it in listen mode, and then n sockets can connect to it. The code: Socket newSocket = listeningSocket.Accept(); returns a socket. I can communicate on newSocket, and listeningSocket goes
13
3212
by: joe215 | last post by:
I want my users to send emails from a Windows app that I am developing in Visual Basic.NET 2003. I found a good example of sending email to a SMTP server using the SmtpMail class. However, using this, it seems, that the user must install IIS on their computer. Isn't there a class that will detect whatever mail server is available on a computer and use that? How do I create this functionality without having the user add any other...
17
1757
by: Adam | last post by:
I need a console application to send me an e-mail....in the past I have use SQL Server's mail messaging to send my e-mails for console applications, but often the SQL Server mail message will not get sent because the SQL Server times out....In my web pages I use the Web MailMessage object, and it does very well....Can I use the Web MailMessage object in a console application, if so how do I set it up, if not what options are there other...
7
2305
by: Bill English | last post by:
How do I send an object from one computer to another? -- I am a 14 year old C# developer, I am completely self taught, so please don't get mad if I ask a stupid question. Thanks.
5
1220
by: VenuGopal | last post by:
Hi, My client uses Win 98. The email part does not work in Win98. I read the documentation and i find that System.Web is not supported in Win98. Now How do i send email on a win 98 platform. Thnks and this is very urgent Venugopal
2
1428
by: ZorpiedoMan | last post by:
I'm new to the world of sockets, and this question is not VB specific: If multiple clients access the same server on the same port, and the server is set up to do some async communication, does the server's response back to all the clients on that port, or just to the one who sent the request? In other words: Client One - Request Data From Server (It takes a few seconds for the server to get the answer)
3
1493
by: derSchweiz | last post by:
Hi, Experimenting with sockets, and I think I got it half working. I have the following code: Private Sub socket_receive(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated Dim bytesRec As Integer Dim i As Integer = 0 Dim data1 As Net.Sockets.Socket = cidServer.Accept() 'this line is
8
2482
by: Mike Owen | last post by:
Hi, I am using the following code to send email on a Windows 2003 Web Server: Imports System.Net.Mail ........ Dim msgmail As New MailMessage msgmail.To.Add(New MailAddress(objMember.EmailAddress)) msgmail.From = New
0
1152
by: richard.charts | last post by:
Well, unfortunately, I couldn't get any answer on the msdn forums, so I'll give it a shot here. Real question at the bottom. --------------------------------------------------------------------------------------------- What new functionality is added to this feature in Windows XP Service Pack 2? Restricted traffic over raw sockets Detailed description
0
8392
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8912
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8669
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4403
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.