API of OA System

2013/09/13 16:12

1. Insert Webmail Login-box on Website

Suppose that the Webmail website is "http://xxx.com/mail", if you want to insert Webmail login-box on website, you can add the following codes on the website.

<form action="http://xxx.com/mail"method=post>

Full account:<input type=text name="fm_strAccount">

Enter password:<input type=password name="fm_strPassword">

<inputtype=submit value='login Webmail'>

</Form>


2. Synchronous Update the Modified OA System Password to AAMail

Suppose that the Webmail website is "http://xxx.com/mail", after modified the OA system password, you can synchronous update this password to AAMail via "password.asp". There are two ways to synchronous update the password, GET or POST.

2.1 Synchronous update the password with GET

http://xxx.com/mail/password.asp?

acc=ACCOUT&pwd=NEW_PASSWORD&old=OLD_PASSWORD&jump=1&url=URL

"password.asp" reads the new and old password from URL. When the old password is tested successfully, then it can be modified to a new password. After the modification, it can be jumped to a specified page. Note that if the password contains special characters, such as "&", "/", "?" etc., then you have to encode the URL.

Parameter

Example

Description

acc

xxxx@test.com

Full account

pwd

654321

New password. Pay attention to encode the URL if there are special characters.

old

123456

Old password. Pay attention to encode the URL if there are special characters.

jump

0 or 1

Whether to jump page after the modification. The default value is "1".

url

login.asp

The target page which needs to be jumped after the modification. It can be blank.

2.2 Synchronous update the password with POST

http://xxx.com/mail/password.asp?jump=1

Synchronous update the password with POST can achieve the same function with GET method, but there will be four fields come from "password.asp" with POST method, they are, "fm_strAccount", "fm_strPassword", "fm_strOldPassword" and "fm_strGoBack".

Parameter

Example

Description

fm_strAccount

xxxx@test.com

Full account

fm_strPassword

654321

New password.

fm_strOldPassword

123456

Old password.

fm_strGoBank

login.asp

The target page which needs to be jumped after the modification. It can be blank.


3. Go to Webmail from the OA System Directly

Suppose that the Webmail website is "http://xxx.com/mail", if you want to add a link on OA system to allow users going to Webmail directly by clicking that link without repeatedly entering the username and password to login again, and send the username and password to "login.asp" to jump page with GET or POST method.

3.1 Jump to Webmail with GET

http://xxx.com/mail/login.asp?acc=ACCOUNT&pwd=PASSWORD&go=X

Because the URL address contains the plaintext password which will be displayed in the address bar, so jump to Webmail with GET method may reveal your password. If you have to use the GET method, we recommend you encrypt the password with MD5.

Parameter

Example

Description

acc

xxxx@test.com

Full account.

pwd

654321

Plaintext password or MD5 (password). Pay attention to encode the URL if there are special characters.

go

0/1/4

"0"="mailbox summary (default)", "1"="mailing list", "4"="compose mail".

3.2 Jump to Webmail with POST

http://xxx.com/login.asp?go=X

Convert the "onClick" of this link to POST via javascript, and send two fields to "login.asp", they are, "fm_strAccount" and "fm_strPassword".

Parameter

Example

Description

fm_strAccount

xxxx@test.com

Full account.

fm_strPassword

654321

Plaintext password or MD5 (password). Pay attention to encode the URL if there are special characters.

go

0/1/4

"0"="mailbox summary (default)", "1"="mailing list", "4"="compose mail".


4. Notice NewMail

AAMail emailmessages are stored in the database, so the OA system can directly access thedatabase to see whether there are new mails. We will introduce how to noticethe new mails in details.

4.1 AAMailDatabase Connection Parameters

AAMail database connectionparameters are stored in the "[Database]" section of"c:\AAMail\data\mailserver.ini". OA system can directly access"mailserver.ini" and get AAMail database connection parameters.

Parameter

Description

DataSource=xxx\SQLExpress

SQL Server data source.

DatabaseName=sqlmail

AAMail database name, the default name is "sqlmail".

AuthSSPI=1

Authentication method. "0"="username+password", "1"="Windows integration authentication".

Userld=sa

Account of SQL Server.

Password=12345678

Password of the account.

4.2 Get Message Info of the Account

AAMail stores mail messages in "WebReceive" table. The specific operations are as follows.

1) Get the total number of the mails: "select count(*) from webreceive where account='xxx@xxx.com'".

2) Get the number of new mails: "select count(*) from Webreceive where account='xxx@xxx.com' and isread=0".


5. Write a Database Record to Send Mails Directly

You can write a record to "WebSent" table to realize directly sending mails.

5.1 AAMail Database Connection Parameters

AAMail database connection parameters are stored in the "[Database]" of "c:\AAMail\data\mailserver.ini". OA system can directly access "mailserver.ini" and get AAMail database connection parameters.

Parameter

Description

DataSource=xxx\SQLExpress

SQL Server data source.

DatabaseName=sqlmail

AAMail database name, the default name is "sqlmail".

AuthSSPI=1

Authentication method. "0"="username+password", "1"="Windows integration authentication".

Userld=sa

Account of SQL Server.

Password=12345678

Password of the account.

5.2 Write Websent Records to Send Mails Directly

AAMail sendings are stored in websent table, and a record stands for a pending sendings. OA mail system writes a websent record with an appropriate value to the database, and then AAMail will read this record and then perform mail encoding and send the mail.

Please see the following "Websent Value Explanatory Table". The "MailId" is the unique ID, and the format of AAMail mail ID is "YYYYMMDD+NNNNNNNN", that is, "Year Month Day + 8 sequence numbers". We recommend modifying the first two "YY" to "AA", that is, "AAYYMMDD+NNNNNNNN", which will avoid repetition.

WebSent Value Explanatory Table

Field

Name

Type

Value Description

Mailld

Mail ID

Varchar[16]

Primary key, such as "AA120101NNNNNN".

Account

Account

Varchar[255]

It must be full account, such as "xx@123.com".

Manager

Manager Account

Varchar[255]

Empty

IPaddress

IP Address

Varchar[64]

Empty

MailSize

Mail Size

Int

0

MailFrom

Sender

Nvarchar[255]

It can be full account, e.g. "XX" &lt; xx@123.com&gt.

MailTo

Recipient

Ntext

One recipient, or multiple recipients separated by comma.

MailCc

Carbon Copy

NText

One recipient, or multiple recipients separated by comma.

MailBcc

Blind Carbon Copy

NText

One recipient, or multiple recipients separated by comma.

MailDate

Mail Date

Varchar[32]

YYYY-MM-DD HH:NN:SS

MailSubject

Mail Subject

NText

Less than 1024.

MailBodyType

Mail Body Type

Int

Choose one type between "0=TEXT mail" and "1=HTML mail".

MailBodyText

Mail Body Text

NText

Related to "MailBodyType".

MailBodyHtml

Mail Body Html

NText

Related to "MailBodyType".

attachmentflag

Attachment Flag

Int

"0=No attachment", "2=Attachment".

checkupstatus

Checkup Status

Int

0

savetodraft

Save to Draft

Int

0

savetosent

Save to Sent

Int

"0= Do not save to Sent", "1=Save to Sent".

priority

Urgent or not

Int

"0=Normal", "1=Urgent".

MailStatus

Sending Flag

Int

1

replyto

Reply to

Nvarchar[255]

Empty

isneedreceipt

Receipt Flag

Int

"0=Do not ask for receipt", "1= Ask for receipt".

sendtype

Send Type

Int

0

Sendtime

Send Time

Varchar[32]

YYYY-MM-DD HH:NN:SS

5.3 Send a Mail with Attachment

It is a little more complex when send a mail with attachments. You need to write two records, they are, websent and websentattach. Suppose that a new mail's mail ID is "AA12010100000001", and this mail has two attachments, such as "xxxx.doc" and "yyy.xls".

1) Generate specified attachment names for these two attachments, such as "AA12010100000001_0001.dat" and "AA12010100000001_0002.dat".

2) Generate a new file for "xxx.doc", such as "c:\AAMail\data\mail\000000\ AA12010100000001_0001.dat". Write "\r\n\r\n" four bytes into the new file firstly, and then read the content of "xxx.doc" file and append to it.

3) Write a record to websentattach table for "xxx.doc". For the specific value, please see the table below.

4) Generate a new file for "yyy.xls", such as "c:\AAMail\data\mail\000000\AA12010100000001_0002.dat". Write "\r\n\r\n" four bytes to the new file, and then read the conent of "yyy.xls" file and append to it.

5) Write a record to websentattach table for "yyy.xls". For the specific value, please see the table below.

6) Write a record to websent table according to "5.2 Write Websent Records to Send Mails Directly". Note that the value of "attachmentflag" must be set as "2" to indicate that this mail has attachments.

WebSentAttach Value Explanatory Table

Field

Name

Type

Value Description

Maild

Mail ID

Varchar[255]

Primary key, such as "AA12010100000001".

AttachId

Attachment ID

Varchar[16]

Primary key, "0001" or "0002" etc.

Account

Account

Varchar[255]

It must be full account, such as "xx@123.com".

Location

Location

Int

0

Direction

Direction

Int

0

Attachtype

Attachment Type

Int

0

ContentType

Content Type

Varchar[255]

Attachment content type, such as "application/octet-stream".

AttachSize

Attachment Size

Int

The original size of the attachment.

AttachName

Attachment Name

Nvarchar[255]

Attachment name.

StartTime

Upload Time

Varchar[32]

Empty


 



Related: