VB.NET + Read Email - insert into Database

I am building an application that checks to see if an email has come into outlook, this part i have so far, but is it possible to read the email and insert value from the email into a database.

The email is a standard format and is just text, what i want to do is take the value and insert them into the database.

ie:

Account #: 12345678
Customer Name: John Smith
Customer Email: jsmith@email.com

Each email is setup the same way with the same fields, so i want to take the 12345678 and insert it, how do i do this.

thanks
dkilbyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
Hi dkilby,

Instead of using Outlook, see http://www.lesnikowski.com/Projects/Mail/Index.aspx

Cheers!
dkilbyAuthor Commented:
The email is coming from Exchange Server - isn't the link above only for POP3 accounts
Éric MoreauSenior .Net ConsultantCommented:
I use it to read from an Exchange server.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

dkilbyAuthor Commented:
ok i am trying to connect to the exchange server and get the following error.

Additional information: No connection could be made because the target machine actively refused it

this is what i put in

        Dim pop3 As Pop3 = New Pop3
        pop3.User = 'my domain account login'
        pop3.Password = 'my domain account password'
        pop3.Connect('exchange server address')

is this correct, the error occurs when it get to pop3.Connect
Éric MoreauSenior .Net ConsultantCommented:
Is the Pop3 service is started on your Exchange Server? It has to be started.
dkilbyAuthor Commented:
i don't believe it is, and i don't have access to the actual Exchange Server - does this mean this will not work for me?
Éric MoreauSenior .Net ConsultantCommented:
The Pop3 service must be started to be able to use the protocol against an Exchange server.
dkilbyAuthor Commented:
Ok i have figured out how to pull the body of the email into a string, now just need to figure out how to pull the values of from the string.

i was thinking i know the fields so is it possible to find the position of the fields and then take the value in between.

ie

strBody = "Account #: 12345678Customer Name: John SmithCustomer Email: jsmith@email.com"

so Account value would be between 10 and 20 if counting characters.

they may be an easier way too.

Thanks
Éric MoreauSenior .Net ConsultantCommented:
>>i was thinking i know the fields so is it possible to find the position of the fields and then take the value in between.

That is probably the easier way to go.
dkilbyAuthor Commented:
but how do i find the position of each field name so the end of Account #: and the beginning of Customer Name: so i know the area to use as the value
Éric MoreauSenior .Net ConsultantCommented:
try something like this:

        Dim intStop As Integer
        Dim strBody As String
        Dim strResult1 As String
        Dim strResult2 As String
        Dim strResult3 As String

        strBody = "Account #: 12345678Customer Name: John SmithCustomer Email: jsmith@email.com"

        intStop = strBody.IndexOf("Customer Name:")
        strResult1 = strBody.Substring(0, intStop)
        strBody = strBody.Remove(0, intStop)
        strResult1 = strResult1.Replace("Account #:", "").Trim

        intStop = strBody.IndexOf("Customer Email:")
        strResult2 = strBody.Substring(0, intStop)
        strBody = strBody.Remove(0, intStop)
        strResult2 = strResult2.Replace("Customer Name:", "").Trim

        strResult3 = strBody.Replace("Customer Email:", "").Trim

        MessageBox.Show(strResult1 & Environment.NewLine & strResult2 & Environment.NewLine & strResult3 & Environment.NewLine)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dkilbyAuthor Commented:
Thanks for all your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.