By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,505 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,505 IT Pros & Developers. It's quick & easy.

Simple mail application

P: n/a
Hi,

I want to write a very very simple mail application which my father can
use (maybe then I will be able to send and receive emails from him).
This application will have a text box, where he will type a message,
and a button. Once he presses this button the application will send an
email to me (my email address will be hardcoded). I don't think that
it can get any simpler.

Problem is that how to send email from standalone machine with just
internet connection? He, of course doesn't have any SMTP server or any
thing like that on his machine. So is it even possible? It can't be
that hard. Can anybody pass me a code that sends email just by using
internet connection?

Thanks

Nov 21 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
Check out 'System.Web.Mail' namespace

One thing though: SPAM filter could catch these types of messages & you may
have to apply to go on a white list because they think you are SPAMMING

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2

P: n/a
there's a bunch of these out there (see
http://www.codeproject.com/com/smtp.asp for example).

why not just sign him up for one of the web-based services? they are
free...

Cheers.
---
http://code.box.sk
nemo me impune lacessit

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #3

P: n/a
I have signed him up...but he wants to use something simple - very
simple.

Also, all of those example codes require SMTP server. Like I said, he
doesn't have SMTP server. He is on WinXP with internet connection. I
hope it is possible to just send an email without any server.

Nov 21 '05 #4

P: n/a
while it is in theory possible to have him connect directly (via your
program) to your SMTP server (i.e. the server that processes your
email), I am not sure that this is your esiest approach (the command
that you will need to send are here
http://www.faqs.org/rfcs/rfc821.html)

he WILL need to connect to a server to send mail -- there is no way
around this (this is how mail gets sent).

there is a c# sample of how to write a simple client here:
http://www.csharphelp.com/archives/archive122.html

Cheers.
---
http://code.box.sk
nemo me impune lacessit

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #5

P: n/a

<c j anderson>; "mcp" <st*********@hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP15.phx.gbl...
http://www.faqs.org/rfcs/rfc821.html)


Using the above plus the tcpClient help in VS I contructed this. I am sure
it can be improved (quick attempt) and there is no validation on the return
strings:

Tested and works:

Imports System.Net.Sockets
Imports System.Text

Dim tcpClient As New TcpClient()
Try
tcpClient.Connect("mail.btopenworld.com", 25)
Dim networkStream As NetworkStream = tcpClient.GetStream()

If networkStream.CanWrite And networkStream.CanRead Then

' HELO
' Does a simple write.
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("HELO
<yourdomain.com>" & vbCrLf)
networkStream.Write(sendBytes, 0, sendBytes.Length)

' Reads the NetworkStream into a byte buffer.
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0,
CInt(tcpClient.ReceiveBufferSize))

' Returns the data received from the host to the console.
Dim returndata As String = Encoding.ASCII.GetString(bytes)
MsgBox((returndata))

' MAIL FROM
sendBytes = Encoding.ASCII.GetBytes("MAIL
FROM:<fr**********@hisdomain.com>" & vbCrLf)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes2(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes2, 0,
CInt(tcpClient.ReceiveBufferSize))
returndata = Encoding.ASCII.GetString(bytes2)
MsgBox((returndata))

' RCPT TO
sendBytes = Encoding.ASCII.GetBytes("RCPT
TO:<to********@yourdomain.com>" & vbCrLf)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes3(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes3, 0,
CInt(tcpClient.ReceiveBufferSize))
returndata = Encoding.ASCII.GetString(bytes3)
MsgBox((returndata))

' DATA
sendBytes = Encoding.ASCII.GetBytes("DATA" & vbCrLf)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes4(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes4, 0,
CInt(tcpClient.ReceiveBufferSize))
returndata = Encoding.ASCII.GetString(bytes4)
MsgBox((returndata))

' Finally the message
Dim txtData As String = _
"Date: 15 May 2005 11:00:00" & vbCrLf & _
"From: fr**********@hisdomain.com" & vbCrLf & _
"To: to********@yourdomain.com" & vbCrLf & _
"Subject: This is a test message" & vbCrLf & vbCrLf & _
"This is the body of the message" & vbCrLf & "." & vbCrLf

'Message
sendBytes = Encoding.ASCII.GetBytes(txtData)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes5(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes5, 0,
CInt(tcpClient.ReceiveBufferSize))
returndata = Encoding.ASCII.GetString(bytes5)
MsgBox((returndata))

' Close connection
tcpClient.Close()

Else
If Not networkStream.CanRead Then
MsgBox("You can not write data to this stream")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
MsgBox("You can not read data from this stream")
tcpClient.Close()
End If
End If
End If
Catch ex As Exception
MsgBox(ex.ToString())
End Try
Nov 21 '05 #6

P: n/a
"Paul Remblance" wrote in message news:3e************@individual.net...
tcpClient.Connect("mail.btopenworld.com", 25)


Sorry, this needs to be your SMTP server for your ISP.
Nov 21 '05 #7

P: n/a
www.vbip.com
very good tutorial.

Sehboo wrote:
Hi,

I want to write a very very simple mail application which my father can
use (maybe then I will be able to send and receive emails from him).
This application will have a text box, where he will type a message,
and a button. Once he presses this button the application will send an
email to me (my email address will be hardcoded). I don't think that
it can get any simpler.

Problem is that how to send email from standalone machine with just
internet connection? He, of course doesn't have any SMTP server or any
thing like that on his machine. So is it even possible? It can't be
that hard. Can anybody pass me a code that sends email just by using
internet connection?

Thanks

Nov 21 '05 #8

P: n/a
In message <11********************@o13g2000cwo.googlegroups.c om>, Sehboo
<ma*********@hotmail.com> writes
Hi,

I want to write a very very simple mail application which my father can
use (maybe then I will be able to send and receive emails from him).
This application will have a text box, where he will type a message,
and a button. Once he presses this button the application will send an
email to me (my email address will be hardcoded). I don't think that
it can get any simpler.

Problem is that how to send email from standalone machine with just
internet connection? He, of course doesn't have any SMTP server or any
thing like that on his machine. So is it even possible? It can't be
that hard. Can anybody pass me a code that sends email just by using
internet connection?

Thanks


If he has got an Internet connection then this must be via an ISP. I
don't know of any ISP that does not offer email services. So why not use
CDO to connect to their SMTP server to send the emails.

1.. Store his outgoing emails in your our little database.
2.. Connect via CDO to his ISP's SMTP server to send them.
3.. Connect via CDO to his POP account to download your emails.

Kind Regards,
--
Andrew D. Newbould E-Mail: ne********@NOSPAMzadsoft.com

ZAD Software Systems Web : www.zadsoft.com
Nov 21 '05 #9

P: n/a

"Sehboo" <ma*********@hotmail.com> wrote in message
news:11********************@g49g2000cwa.googlegrou ps.com...
I have signed him up...but he wants to use something simple - very
simple.

Also, all of those example codes require SMTP server. Like I said, he
doesn't have SMTP server. He is on WinXP with internet connection. I
hope it is possible to just send an email without any server.


His ISP doesn't provide email to him? If they do, he's already got access to
an SMTP server that your program can talk to.
Nov 21 '05 #10

P: n/a
Problem is that how to send email from standalone machine with just


internet connection? He, of course doesn't have any SMTP server or
any thing like that on his machine. So is it even possible? Itcan't be that hard. Can anybody pass me a code that sends email justby using internet

connection?

He does not need his own SMTP server. He can send it directly to
the SMTP server of the recipient, so if you're hard coding your email address
you can also hard-code your SMTP server. If you want him to be able to change
the recipient email address, then you'll need code to look up the MX record of
the domain to determine the mail server to send to. There are several solutions
to this if you do not know how, including IPWorks MX
component.

Regards,
Lance R.
/n software
http://www.nsoftware.com/

-

Nov 21 '05 #11

P: n/a

<la****@nsoftware.removeme.com> wrote in message
news:Ap3ie.4$yc.1@trnddc02...

He does not need his own SMTP server. He can send it directly to
the SMTP server of the recipient, so if you're hard coding your email address you can also hard-code your SMTP server. If you want him to be able to change the recipient email address, then you'll need code to look up the MX record of the domain to determine the mail server to send to. There are several solutions to this if you do not know how, including IPWorks MX
component.


This may well not work. Many servers now block direct to MX mailings,
mailings from addresses without proper reverse lookup entries and mailings
from systems found in dynamic address pools.
Nov 21 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.