954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Receive Email in vb.net 2005

Hi Professionals,

I am currently working on a mass emailing system. I am using Microsoft Visual Studio 2005. With windows IIS in Windows XP SP3. My program can send mass emails using System.Net.Mail namespace found in .NET 2.0 but i have no idea on how to implement the receiving emails part.

Any advice, links, hints, tips, etc would be greatly appreciated.

Please accept my gratitude in advance.

Best Regards,
Md Azmil

milhero
Light Poster
31 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Common way to receive email is a POP3 server. .NET doesn't provide a built-in POP3 server so you'll have to write one of your own or get a third-party POP3 server. To get you started, try googling http://www.google.com/search?q=vb.net+pop3+server .

HTH

P.s. I hope I don't help to build yet another spamming site ;)

Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
 

Are you trying to write a mailserver from the ground up to listen on port 25 and accept inbound mail messages from remote MTAs, or are you wanting to use a POP3/IMAP/Exchange connection to download your email from your mailserver?

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 
Are you trying to write a mailserver from the ground up to listen on port 25 and accept inbound mail messages from remote MTAs, or are you wanting to use a POP3/IMAP/Exchange connection to download your email from your mailserver?

I am not sure if either one is the one I want. But what I sure of is I'm working on a mass email system for my school project. I am using Microsot Visual Studio 2005, IIS and Microsoft SQL Server 2005. I am also using vb.net as my language and doing it in windows form.

I am able to send email using the System.Net.Mail namespace. But i am not sure what to use to program my system to display and receive emails.

Please advice.

milhero
Light Poster
31 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

I think you have a fundamental misconception of how email works. Just because you sent an email doesn't mean you have to listen for it. Spammers send email all the time from fictitious addresses and never listen for responses.

In order to send email you need to do one of two things:
1) Create your own mailserver listening on port :25 for inbound email.
2) Connection to an existing mailserver (Your school's, ISPS, etc)

Everything falls under one of those two options

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

Just because you sent an email doesn't mean you have to listen for it. Spammers send email all the time from fictitious addresses and never listen for responses.

In order to send email you need to do one of two things: 1) Create your own mailserver listening on port :25 for inbound email.


Firstly, I agree on the "Just because you sent an email doesn't mean you have to listen for it" but my project requires me to capture received emails. Secondly, I am not a spammer. And third, can the first option "1) Create your own mailserver listening on port :25 for inbound email." be used to capture receive emails?

milhero
Light Poster
31 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Yes it can but you're probably looking at a few months worth of development to get your first version of a mailserver live. I would highly suggest using an existing mailserver and querying it for messages with POP3/Image/Exchange.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 
Yes it can but you're probably looking at a few months worth of development to get your first version of a mailserver live. I would highly suggest using an existing mailserver and querying it for messages with POP3/Image/Exchange.


Is the mail server free?

milhero
Light Poster
31 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

That depends on what mailserver you decide to use....

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 
That depends on what mailserver you decide to use....

Ok. But is there any open source(free) or windows XP integrated mailserver that i can use?

Please advise.

milhero
Light Poster
31 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Ok. But is there any open source(free) or windows XP integrated mailserver that i can use?

Please advise.


You should be able to simply tap into any mailserver with your username and password.

do some research on the System.Net.Mail namespace.

I believe you could even use something like hotmail or Gmail , though i'm not sure.

Zandermander
Light Poster
30 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 
You should be able to simply tap into any mailserver with your username and password.

I'm sorry but my username and password of what?

milhero
Light Poster
31 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 
I'm sorry but my username and password of what?


Your username and password the the mailserver, aka your account.

Can you post the code of how you sent the email? If you sent it, you should have specified the mailserver you used, unless your using a method I am unaware of.

Zandermander
Light Poster
30 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 

Your username and password the the mailserver, aka your account.

Can you post the code of how you sent the email? If you sent it, you should have specified the mailserver you used, unless your using a method I am unaware of.


Sure. Below are codes for sending email:- Imports System
Imports System.Net.Mail

Public Class Email

Private mailMessage As New Net.Mail.MailMessage()
Dim attachment As Net.Mail.Attachment

Public Sub SendMassEmail(ByVal MsgFrom As String, ByVal MsgTo As String, ByVal MsgSubject As String, ByVal MsgBody As String)

'This procedure takes string array parameters for multiple recipients and files
Try

' Pass in the message information to a new MailMessage
mailMessage = New Net.Mail.MailMessage(MsgFrom, MsgTo, MsgSubject, MsgBody)


' Adding attachments
Dim attachment As Net.Mail.Attachment = New Net.Mail.Attachment(ofdAttach.FileName)
mailMessage.Attachments.Add(New Attachment(txtAttach.Text))

' Create an SmtpClient to send the e-mail
Dim mailClient As New SmtpClient("152.226.152.152") ' = local machine IP Address


' Use the Windows credentials of the current User
mailClient.UseDefaultCredentials = True


' Pass the message to the mail server
mailClient.Send(mailMessage)


' Optional user reassurance:
MessageBox.Show(String.Format("Message Successfully Sent!" & vbCrLf & vbCrLf & "Message Subject: {0}" & vbCrLf & "FROM: {1}" & vbCrLf & "TO: {2}", MsgSubject, MsgFrom, MsgTo), "EMail", Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.Information)


' Housekeeping
mailMessage.Dispose()


'Error Checking
Catch ex As FormatException

MessageBox.Show(ex.Message & " :Format Exception")

Catch ex As SmtpException

MessageBox.Show(ex.Message & " :SMTP Exception")

End Try

End Sub

Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

SendMassEmail(txtFrom.Text, rtbTo.Text, txtSubj.Text, txtMsg.Text)

End Sub

End Class

milhero
Light Poster
31 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Alright, I did some research and decide to use POP3 to retrieve email and already used SMTP to send email. Can you please give me a headstart with regards to using POP3 in vb.net(Microsoft Visual Studio 2005)?

Thank you.

milhero
Light Poster
31 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You