Author |
|
PaulGQ Newbie
Joined: 20 May 2006 Location: United States
Online Status: Offline Posts: 1
|
Posted: 20 May 2006 at 5:49am | IP Logged
|
|
|
Here is what we need to do.
When an email arrives with "Ticket Sold" in the subject line, we need some kind of POP3 product that will monitor the mailbox, read the body of the email, and parse 4 text values into our ASP/SQL database.
The values in the body will look something like:
Number: 009727255
Price: $50.00
Type: Web Sale
Contact: Sally
The mail should remain in the mailbox until Outlook Express checks it and picks up the message.
By this time, an entry will already be added to our database.
What product is offered that can handle this and help us automate the entering in of this data manually?
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 22 May 2006 at 10:09am | IP Logged
|
|
|
If you do not need to send mails in your applications, you may purchase MailBee POP3 component only.
MailBee POP3 is an ActiveX component which enables your application to receive, parse and manage e-mail. You can learn more at: MailBee POP3 Component homepage
If you need to periodically download mail and parse new messages, we can recommend you the following solution.
First of all, some of kind of periodic poll service is required.
If you have access to MS SQL server, you can use SQL Agent service to create job object (can be done in a minute via SQL Server Enterprise Manager) which will run your script periodically.
If you do not have MS SQL server, you can write simple desktop VB app which has timer placed and on the form. Timer event procedure should execute VB code you use for polling the mailbox. While the app is run and timer ticks, mailbox is periodically polled.
Secondly, since POP3 protocol has no mechanism to determine whether a message has been already downloaded, you should keep a list of identifiers of already downloaded messages in a local database maintained by your application.
Any time your application searches the mailbox for new messages, it queries the database for each message in the mailbox to determine if a message has already been downloaded. If the identifier of the particular message has not been found in the database, this message is new. You can use Unique-ID as the message identifier.
For more details and code samples you can refer to MailBee Objects Documentation / MailBee Tutorials / Receiving new messages from POP3 server. MailBee Objects Documentation can be accessed after installation of MailBee Objects (MailBee POP3 component in your case).
As for message parsing, you can use the following code (in VB syntax)
Code:
' Function which operates with results of parsing
Sub DoAction(number, price, type, contact)
' Add here your implementation of processing results.
' For example, store results in database.
End Sub
' Parsing function
Function ParseMail(msg)
Dim tmp1, tmp2, number, price, type, contact
' If an email has "Ticket Sold" in the subject field
If InStr(msg.Subject, "Ticket Sold") > 0 Then
' Split message by lines
tmp1 = Split(msg.BodyText, vbCrLf)
For Each line In tmp1
tmp2 = Split(line, ":")
' If tmp2 has 2 elements
If UBound(tmp2) = 1 Then
tmp2(0) = Trim(tmp2(0))
tmp2(1) = Trim(tmp2(1))
If tmp2(0) = "Number" Then
number = tmp2(1)
End If
If tmp2(0) = "Price" Then
price = tmp2(1)
End If
If tmp2(0) = "Type" Then
type = tmp2(1)
End If
If tmp2(0) = "Contact" Then
contact = tmp2(1)
End If
Call DoAction(number, price, type, contact)
End If
Next
End If
End Function
|
|
|
You should call ParseMail function for every message you download from mail server.
Our team can also implement the features you need into your application in terms of custom project. Please let us know if you interested in this by mailing to support@afterlogic.com.
Regards,
Alex
|
Back to Top |
|
|