473,382 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Simple mail application

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
11 1662
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
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
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
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

<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
"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
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
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

"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
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

<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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Paul Moore | last post by:
I hit a problem yesterday with my mail connection. In a desparate attempt to understand what was going on, I wanted to log the connection traffic. After a bit of searching, I found a post on c.l.p...
19
by: Bill | last post by:
I have searched through the posts for a question like mine but have only found much more complicated responses. On single record view of a form I have an email address field. I merely want to...
9
by: savvy | last post by:
i'm trying to compile a simple console application for sending a mail, my main idea is to schedule it to a particular time for sending mails using the windows schedular task lateron. Therefore i...
2
by: HvG | last post by:
I'm sure this is a trivial question, but I cannot create an Outlook Object from a WebForm app, but can from a console app. or a Windows app. My COM knowledge is very poor sorry. ...
1
by: Nick Gilbert | last post by:
Hi, I'm writing a Windows Forms application in .NET and I need to send an e-mail from it. As it's NOT asp.net, I don't have access to an SMTP server so I will have to send the e-mail using...
5
by: Logickle | last post by:
Hi, all. I'm working on an application which requires communicating session info between separate web apps running on the same web server. The out of process server method sounded ideal, and...
5
by: Olivier/Noetika | last post by:
would like to send messages from my vb application with the user default mail software. That's to say preparing content, attachement and let user selecting the "to" option with it's own friends list....
4
by: Tony M | last post by:
VS 2005 - XP media - VB .net - winforms - .net 2.0 Just trying to send an email, here is the code and the error message that I get. I can't figure out how to fix it?
5
by: simononestop | last post by:
Hi im totally new to perl this is my first go at using it (I normally use asp). I have set up a form with a cgi script from demon hosting. I have edited the script and the form works it sends me an...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.