[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB.NET + Read Email - insert into Database

Posted on 2006-04-15
12
Medium Priority
?
380 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:dkilby
  • 6
  • 6
12 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 16460987
Hi dkilby,

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

Cheers!
0
 

Author Comment

by:dkilby
ID: 16461000
The email is coming from Exchange Server - isn't the link above only for POP3 accounts
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 16461002
I use it to read from an Exchange server.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dkilby
ID: 16461055
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
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 16461066
Is the Pop3 service is started on your Exchange Server? It has to be started.
0
 

Author Comment

by:dkilby
ID: 16461070
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?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 16461074
The Pop3 service must be started to be able to use the protocol against an Exchange server.
0
 

Author Comment

by:dkilby
ID: 16461251
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
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 16461304
>>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.
0
 

Author Comment

by:dkilby
ID: 16461314
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
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 16461370
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)
0
 

Author Comment

by:dkilby
ID: 16462194
Thanks for all your help
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month19 days, 23 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question