Home All Groups Group Topic Archive Search About

Simple mail application

Author
14 May 2005 12:37 AM
Sehboo
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

Author
14 May 2005 6:39 AM
Crouchie1998
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
Author
14 May 2005 6:46 AM
c j anderson, mcp
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 ***
Author
14 May 2005 3:13 PM
Sehboo
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.
Author
15 May 2005 6:31 AM
c j anderson, mcp
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 ***
Author
15 May 2005 9:43 AM
Paul Remblance
<c j anderson>; "mcp" <stand__s***@hotmail.com> wrote in message
news:edJQDfRWFHA.2692@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:<from.addr***@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.addr***@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: from.addr***@hisdomain.com" & vbCrLf & _
                "To: to.addr***@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
Author
15 May 2005 9:48 AM
Paul Remblance
"Paul Remblance" wrote in message news:3eojtaF3pa9nU1@individual.net...
>            tcpClient.Connect("mail.btopenworld.com", 25)

Sorry, this needs to be your SMTP server for your ISP.
Author
16 May 2005 2:22 PM
NetworkElf
"Sehboo" <masoodad***@hotmail.com> wrote in message
news:1116083625.249471.9890@g49g2000cwa.googlegroups.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.
Author
15 May 2005 10:03 AM
Supra
www.vbip.com
very good tutorial.

Sehboo wrote:

Show quoteHide quote
>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
>

>
Author
15 May 2005 6:22 PM
Andrew D. Newbould
In message <1116031046.437346.5***@o13g2000cwo.googlegroups.com>, Sehboo
<masoodad***@hotmail.com> writes
Show quoteHide quote
>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:  newsgroups@NOSPAMzadsoft.com

ZAD Software Systems                Web   :  www.zadsoft.com