-
Oct 11th, 2009, 08:08 PM
#1
Thread Starter
Lively Member
Email Questions
Hey everyone!
My latest project requires both sending and receiving emails.
Now i know how to send emails using a gmail account, but what im having incredible difficulty with, is accepting emails. What i want, is to have a program that both has the ability to send emails, and capture emails being sent to the logged in user, and place them in an inbox list. I was wondering if anyone knew how to receive emails with a program, even temporarily, so that when an email is sent to the user, my program knows about it, and can take the body from the email, and place it in say a textbox.
My idea is simple. My end product will have the ability to receive emails, and i will search through them, and if the body of the email contains key words like, 'open internet' then, i will have my program start the default web browser.
My hope for this, is to be able to text my email these key words to remotely command my computer.
It may seem like a difficult task, but it would be very simple if i could just figure out how to catch incoming emails.
-
Oct 11th, 2009, 08:40 PM
#2
Re: Email Questions
The .NET Framework has inbuilt support for sending email because it's very common for applications to have to send email notifications. Pretty much everyone has their own email client though, so the need for another application to receive email is a rare thing indeed. As such there is no support for it in the Framework. You'll have to implement it yourself at a low level or else configure an email client for your chosen address and automate that.
-
Oct 12th, 2009, 03:38 AM
#3
Re: Email Questions
Assuming your email provider gives you POP3 access to your mailbox, you can try to use something like this to retrieve the emails from it: http://www.vbforums.com/showthread.php?t=584895
EDIT: Posted the wrong link, I actually meant this one: http://www.codeproject.com/kb/IP/POP...hadZHower.aspx
Last edited by chris128; Oct 14th, 2009 at 08:06 AM.
-
Oct 13th, 2009, 12:36 AM
#4
Thread Starter
Lively Member
Re: Email Questions
im sorry i dont know what POP3 is. care to explain? :]
hmm... problem with setting up a server/client relationship with emailing, is it seems somewhat unnecessary. Tell me if im wrong, but couldn't i just use an already known port for gmail or something like that??
If i cannot, please give me any suggestions you have on how to listen on that port for emails, then have the access to that email, and be able to read the body of text.
Thanks for the reply's
-
Oct 13th, 2009, 12:40 AM
#5
Fanatic Member
Re: Email Questions
Check this link for an idea of POP3.
-
Oct 13th, 2009, 12:57 AM
#6
Re: Email Questions
If you don't understand SMTP/POP3 you probably shouldn't be attempting something like this straight away.
reading your e-mails is not listening on a port.
I mean when you say catching e-mails.. it sounds like you're trying to write your own SMTP mailserver or something... but you're talking of a gmai laccount so actually you want to use POP3 to connect to your inbox, but you'd probably be safer writing or using an email client plugin, because you're going to run into trouble where e-mails get deleted from the inbox by either your program or the users email client unless u ensure theyre both set to leave a copy of emails on the server for an amount of time.
I strongly suggest you do some research on POP3 and SMTP before you proceed, then you can make an informed decision and know what to expect and how to design this software better.
-
Oct 13th, 2009, 01:09 AM
#7
Thread Starter
Lively Member
Re: Email Questions
Thanks for the link and the tips both of you.
My idea was to research everything that you guys throw at me. :] so thanks for some ideas.
My program isnt going to keep memory of the entire inbox, but when it receives one, it passes it, and if it contains commands in the body, such as shut down or other key phrases that i define, it will carry out specified commands, like shut down the computer.
Will POP3 allow me to connect to gmail's inbox, and only read the most recent email, based on a timer, and only read it if it has not read it before? is this possible? or so complicated that its worth finding another way to carry out this task.
-
Oct 13th, 2009, 03:01 AM
#8
Re: Email Questions
Firstly for gmail i think you have to enable POP3 access http://mail.google.com/support/bin/a...n&answer=13273
Secondly, yes, all that should be possible.
-
Oct 13th, 2009, 03:55 AM
#9
Re: Email Questions
Why would you want to only read the most recent email on a timer though, what if two emails come in before your timer fires again?
-
Oct 13th, 2009, 07:31 PM
#10
Thread Starter
Lively Member
Re: Email Questions
if i have a timer constantly running, it could check to see if a new email is in place, and if it is, read it. if two emails come at the same time, i suppose that would be the flaw in my idea.
And other ideas on how i could catch/read the emails other than a timer?
-
Oct 13th, 2009, 09:47 PM
#11
Re: Email Questions
I don't see why you can't read all new e-mails each time your timer runs. why just the first? you can either use the read/unread status of the mail message itself or as any client sdo, record the message id somewhere, you know you've dealth with that message.
-
Oct 13th, 2009, 11:00 PM
#12
Thread Starter
Lively Member
Re: Email Questions
yeah that may work. First i guess i have to learn all about POP3.. its already in the framework right? like i dont have to download any dll files or anything? probably just references? or imports?
-
Oct 14th, 2009, 12:38 AM
#13
Re: Email Questions
Originally Posted by manbearpig001
yeah that may work. First i guess i have to learn all about POP3.. its already in the framework right? like i dont have to download any dll files or anything? probably just references? or imports?
Read post #2, keeping in mind that SMTP is the protocol used to send email and POP3 is used to receive it.
-
Oct 14th, 2009, 12:56 AM
#14
Thread Starter
Lively Member
Re: Email Questions
yeah i need to receive the emails, so i need to use POP3, and in post # 2 you only told me that sending emails is built into the framework. do i need to import POP3 in order to read emails?
-
Oct 14th, 2009, 01:03 AM
#15
Re: Email Questions
Originally Posted by manbearpig001
yeah i need to receive the emails, so i need to use POP3, and in post # 2 you only told me that sending emails is built into the framework. do i need to import POP3 in order to read emails?
There's no support for POP3 in the Framework. You need to either implement it yourself at a low-level or else get a pre-built component from somewhere else. I'm not aware of any free ones. There was one written in C# available a few years ago but that went commercial so I guess they decided that the amount of work that had gone into it was worthy of recompense.
-
Oct 14th, 2009, 08:07 AM
#16
Re: Email Questions
I posted the wrong link in my earlier post (shame on me for not noticing).
I have edited it now, take a look at the link in there and see if it helps.
-
Oct 14th, 2009, 06:38 PM
#17
Thread Starter
Lively Member
Re: Email Questions
what do u mean by impliment it at a low level by myself? any tuts on how to do this?? and could i use winsock or something to read emails? or messages being sent from my cellphone?
-
Oct 15th, 2009, 03:35 AM
#18
-
Oct 15th, 2009, 04:32 AM
#19
Re: Email Questions
Originally Posted by chris128
Are my posts invisible?
Only to those asking for help apparently. I'm now aware of a free one.
-
Oct 15th, 2009, 11:40 AM
#20
Fanatic Member
Re: Email Questions
Here is an opensource C#-based API for accessing IMAP.
Koolwired IMAP API
It's a DLL that you will have to set references to.
Google has IMAP.
So far, I have figured out how to successfully connect to my gmail account (works with Google Apps as well).
The only problem I am now having is that I can't figure out how to retrieve emails. lol.
I have found absolutely no documentation and the company has not responded to an email I sent them regarding how to retrieve emails.
Code:
'Specify connection to IMAP server
Dim gSession As New Koolwired.Imap.ImapConnect("imap.gmail.com", 993, True)
'Specify Authentication information
Dim gAuthenticate As New Koolwired.Imap.ImapAuthenticate(gSession, <email>, <password>)
Try
gSession.Open()
gAuthenticate.Login()
gAuthenticate.Logout()
gSession.Close()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
There is an example "Test" project included, but I tried to duplicate the code in VB and modify as needed, but still couldn't get it to work quite right.
Last edited by Seraph; Oct 15th, 2009 at 11:46 AM.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 15th, 2009, 08:00 PM
#21
Thread Starter
Lively Member
Re: Email Questions
BTW chris, the link you posted is exactly what i was looking for, if it was in vb :[ thank you for posting it though. it gave me a really good sense on how to go about this project.
EDIT:
I downloaded the indy dll. and it seemed to work while i wrote my code out, but when i ran the debug, i got a strange error (about the dll im guessing)
code:
Imports Indy.Sockets
Module Module1
Sub Main()
Dim xHost As String = "smtp.gmail.com"
Dim xport As String = "587"
Dim xUsername As String = "email@gmail.com"
Dim xPassword As String = "pass"
Dim xpop3 As New POP3
Dim xcount As Integer
Using xpop3
xpop3.Username = xUsername
xpop3.Password = xPassword
xpop3.Connect(xHost, xport)
Int(xcount = xpop3.CheckMessages)
If (xcount = 0) Then
Console.WriteLine("No messages on account.")
Else
Dim xmsg As New Message
xpop3.Retrieve(1, xmsg)
Console.WriteLine("Subject: " + xmsg.Subject)
Console.WriteLine("From: " + xmsg.From.Text)
Console.WriteLine("Body: " + xmsg.Body.Text)
End If
Try
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
Console.WriteLine("")
Console.WriteLine("Press enter")
Console.ReadLine()
End Try
End Using
End Sub
End Module
Error:
Load Error Message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Source: mscorlib Stack Trace: at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark) at System.Reflection.Assembly.GetTypes() at Indy.Sockets.InitializerComponent.InitializeAssembly(@MetaInitializerComponent Self, Assembly AAssembly) in C:\temp\IndyBuild\IndyNet\Source\Indy.Sockets.IdBaseComponent.pas:line 227 at Indy.Sockets.InitializerComponent.InitComponent() in C:\temp\IndyBuild\IndyNet\Source\Indy.Sockets.IdBaseComponent.pas:line 283 Error #0 Message: Could not load file or assembly 'Mono.Security, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified. Source: Stack Trace: Error #1 Message: Could not load file or assembly 'Mono.Security, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified. Source: Stack Trace:
I have no idea whats wrong. any ideas? :]
Last edited by manbearpig001; Oct 15th, 2009 at 09:05 PM.
-
Oct 16th, 2009, 09:03 AM
#22
Fanatic Member
Re: Email Questions
I think it might be because you are using code to retrieve a message list and are accessing smtp.gmail.com. They won't work together.
If you want to check messages, you will need to use pop.gmail.com:995
Also, Gmail sometimes likes SSL to be turned on but I haven't found how to turn SSL on with that Indy DLL.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 19th, 2009, 03:06 PM
#23
Thread Starter
Lively Member
Re: Email Questions
hmm.. didnt seem to help.
the error is in this line;
Dim xpop3 As New POP3
error is this;
Load Error Message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Source: mscorlib Stack Trace: at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark) at System.Reflection.Assembly.GetTypes() at Indy.Sockets.InitializerComponent.InitializeAssembly(@MetaInitializerComponent Self, Assembly AAssembly) in C:\temp\IndyBuild\IndyNet\Source\Indy.Sockets.IdBaseComponent.pas:line 227 at Indy.Sockets.InitializerComponent.InitComponent() in C:\temp\IndyBuild\IndyNet\Source\Indy.Sockets.IdBaseComponent.pas:line 283 Error #0 Message: Could not load file or assembly 'Mono.Security, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified. Source: Stack Trace: Error #1 Message: Could not load file or assembly 'Mono.Security, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified. Source: Stack Trace:
Thanks for the help everyone. :]
-
Oct 19th, 2009, 03:16 PM
#24
Fanatic Member
Re: Email Questions
Oh. Should have noticed this earlier.
It is looking for another Assembly (DLL): Mono.Security
There are two DLL's that came in the zip file and both must be referenced.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 19th, 2009, 03:27 PM
#25
Fanatic Member
Re: Email Questions
I don't get any errors but I sure as heck can't seem to get a full connection.
It just sits there and locks the window for me.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 19th, 2009, 04:35 PM
#26
Thread Starter
Lively Member
Re: Email Questions
? what zip file gave you a mono.security dll?? i sure as heck dont have one.
-
Oct 19th, 2009, 04:54 PM
#27
Fanatic Member
Re: Email Questions
umm, not sure where i got it from now.
I found a zip folder called pop3.zip and it had the whole Indy.Socket stuff and all of it programmed in C# code with those two DLL files.
I can't figure out where I got it from.
I just uploaded it to my webserver if you wanna download what I had found:
http://www.serysoft.com/files/pop3.zip
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 19th, 2009, 04:57 PM
#28
Thread Starter
Lively Member
Re: Email Questions
:] thanks but the link didn't work :[
EDIT: nvm got it to work! :] thanks a ton!
-
Oct 19th, 2009, 04:58 PM
#29
Fanatic Member
Re: Email Questions
http://www.serysoft.com/files/POP3.zip
I think it's being picky about capitalization...lol
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 19th, 2009, 05:00 PM
#30
Thread Starter
Lively Member
Re: Email Questions
haha.. yeah now when i run debug, it just stays there waiting for something... (i assume what your program does as well)
-
Oct 19th, 2009, 06:18 PM
#31
Fanatic Member
Re: Email Questions
*shrug* My program just goes into Not Responding mode and hangs up.
And that was with or without the extra DLL, because at first I didn't notice it either.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 19th, 2009, 06:27 PM
#32
Thread Starter
Lively Member
Re: Email Questions
well mine just seems like it does not want to connect.. i configured my gmail account to allow pop3.. so that shouldnt be the problem.. i wouldn't have to forward or allow the port im connecting through would i?? i mean im not running any server, just a client. correct?
-
Oct 19th, 2009, 07:16 PM
#33
Fanatic Member
Re: Email Questions
Well, I did not have POP enabled I think.
I'll have to try when I get to work tomorrow.
The little program I'm using for testing is on my work PC.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 20th, 2009, 12:37 AM
#34
Thread Starter
Lively Member
Re: Email Questions
Alrighty well be sure to update this thread if you find anything new out tomarro. :]
-
Oct 20th, 2009, 08:43 AM
#35
Fanatic Member
Re: Email Questions
Well, I just found out if I let it go I get an error.
I was previously letting it go but was probably stopping it just before it errored because I thought it was just hanging up.
I get the following error:
Code:
Indy.Sockets.EIdConnClosedGracefully: Connection Closed Gracefully.
at Indy.Sockets.IOStream.RaiseConnClosedGracefully()
at Indy.Sockets.IOHandlerStack.CheckForDisconnect(Boolean ARaiseExceptionIfDisconnected, Boolean AIgnoreBuffer)
at Indy.Sockets.IOHandlerStack.ReadFromSource(Boolean ARaiseExceptionIfDisconnected, Int32 ATimeout, Boolean ARaiseExceptionOnTimeout)
at Indy.Sockets.IOStream.ReadLn(String ATerminator, Int32 ATimeout, Int32 AMaxLineLength)
at Indy.Sockets.IOStream.ReadLn()
at Indy.Sockets.IOStream.ReadLnWait(Int32 AFailCount)
at Indy.Sockets.TCPConnection.GetInternalResponse()
at Indy.Sockets.TCPConnection.GetResponse(String AAllowedResponse)
at Indy.Sockets.POP3.Connect()
at Indy.Sockets.TCPClientCustom.Connect(String AHost, Int32 APort)
at gNotify.frmMain.Button1_Click(Object sender, EventArgs e) in C:\Users\rburke\Desktop\gNotify2\gNotify\frmMain.vb:line 48
Looks like it is timing out; can't be sure why though.
The data going in is correct.
The only thing I can think of is SSL isn't being explicitly turned on anywhere.
I'll have to go through all the options for the Indy.Socket namespace in the Object Browser and see if I can figure out how to tell the connection it needs to have SSL turned on.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 20th, 2009, 09:16 AM
#36
Thread Starter
Lively Member
Re: Email Questions
haha after reading what you posted, i tried to see what mine did, and it said the same error. the gracefully closed or whatever.
I find it odd that no tutorials with indy.sockets knows about this error...
-
Oct 20th, 2009, 09:18 AM
#37
Fanatic Member
Re: Email Questions
I'm finding some stuff. It looks like another DLL is required to get this working.
I'm looking into it now.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 20th, 2009, 09:26 AM
#38
Fanatic Member
Re: Email Questions
Wow, this isn't simple. lol.
It isn't so simple as just setting a reference to the DLL.
These things are written in Delphi. The SSL libraries required.
Google: Indy.sockets POP3 and SSL
for more info.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Oct 20th, 2009, 09:34 AM
#39
Thread Starter
Lively Member
Re: Email Questions
would it be easier to just use something other than gmail?
-
Oct 20th, 2009, 09:36 AM
#40
Fanatic Member
Re: Email Questions
Either Hotmail or Yahoo! doesn't require SSL; can't remember which one.
Maybe that would work.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|