Documente Academic
Documente Profesional
Documente Cultură
API
JSON & XML
V2.3.4
Last update 05.09.2019
1
INTRODUCTION
Please find here our application programming interface (API) intended to be used as interface with your
application / website component to communicate with Mailpro to send email and optimize your email
deliverability.
You can find the latest version of this document in your Mailpro Account. You can set-up a free account
in order to receive the documentation.
In order to use the API and for security reasons, our support team has to give you and validate your API
Key if you are a free account, so please fill this validation form.
If you are a paid account you can find your API Key inside Mailpro in Configuration->API.
In order to use some of the API methods you will need the Ids of several Mailpro objects, like messages,
address books, campaigns and sender emails. You can find these Ids in all the lists inside Mailpro (as a
column or in the list menu)
And your customer/client Id you can find it inside Mailpro in the top banner or in My Account module.
The client ID is an only number value, so omit any letter.
2
Mailpro API: Email Functions
Page 5 to 74
By default, you can call all functions at max speed of 500 requests per minute on the API.
API Functions
List
Add
Addressbook Del
Edit
List
Add
Emails AddSingle
Del
Edit
List
Add
Message Del
Edit
List
Del
Add
Send AddSingle
AddSingle2
SendingTest
List
Add
TransactionalEmail Del
Edit
SetStatus
Historic List
List
SenderEmail Del
List
Del
ByHour
ByDay
Open
Stats Click
System
EmailSoftare
Country
BadMail
Credits
Account SubscriptionEndDate
PHP
ASP.Net
Code Example Java
Visual Basic
3
Mailpro API: SMS Functions
Page 75 to 91
By default, you can call all functions at max speed of 500 requests per minute on the API.
4
LIST ADDRESSBOOK EMAIL
Description: Get a listing of all Address Books
Method: Get
Call:
Base URL https://api.mailpro.com/v2/addressbook/list.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
AddressBooks[] Contains list of address books
AddressBook[] Identify each address book
AddressBookId ID of the address book
Creation date of this address book
CreationDate
Format : YYYY-MM-DDThh:mm:ss (ISO format)
Title Title of address book
Type 1 for Unsubscription address book, 0 for subscription address book
NumberEmails Number of email in this address book
5
Example of result:
6
ADD ADDRESSBOOK EMAIL
Description: Add an address book (Maximum 100 Address Books)
Method: Post
Call:
Base URL https://api.mailpro.com/v2/addressbook/add.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
AddressBooks[] Contains list of address books
AddressBook[] Identify each address book
AddressBookId ID of the address book
Creation date of this address book
CreationDate
Format : YYYY-MM-DDThh:mm:ss (ISO format)
Title Title of address book
Type 1 for Unsubscription address book, 0 for subscription address book
NumberEmails Number of email in this address book
Example of result:
7
DELETE ADDRESSBOOK EMAIL
Description: Delete an address Book
Method: Post
Call:
Base URL https://api.mailpro.com/v2/addressbook/del.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Result Result of action
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Result>OK</Result>
</mailproapi>
8
EDIT AN ADDRESSBOOK EMAIL
Description: Edit an address Book
Method: Post
Call:
Base URL https://api.mailpro.com/v2/addressbook/edit.xml
Parameters
Name Mandatory Description
APIKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
AddressBook[] Identify the address book
AddressBookId ID of the address book
Creation date of this address book
CreationDate
Format : YYYY-MM-DDThh:mm:ss (ISO format)
Title Title of address book
1 for Unsubscription address book
Type
0 for subscription address book
NumberEmails Number of email in this address book
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<AddressBook>
<AddressBookID>1025</AddressBookID>
<CreationDate>2012-01-02T01:00:00</CreationDate>
<Title>New Example</Title>
<Type>1</Type>
<NumberEmails>545</NumberEmails>
</AddressBook>
</mailproapi>
9
LIST EMAILS
Description: Get a listing of all emails in an address book
EMAIL
Method: Get
Call:
Base URL https://api.mailpro.com/v2/email/list.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Emails[] Contains list of Emails
Email Identify each Emails
IdEmail ID of the Email
IdAddressBook ID of the Address Book
1 for Unsubscription address book, 0 for subscription address book
Field1 Field1
Field2 Field2
Field3 Field3
………
Field25 Field25
10
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Emails>
<Email>
<IdEmail>1025</ IdEmail >
< Email >test@test.com</ Email >
<field1>name</field1>
<field2>first name</field2>
<field25>street</field25>
</Email>
<Email>
< IdEmail >78485</ IdEmail >
< Email >test2@test.com</ Email >
<field1>name</field1>
<field2>first name</field2>
<field25>street</field25>
</Email>
</Emails>
</mailproapi>
11
ADD SEVERAL EMAILS EMAIL
Description: Add one or more emails
Method: Post
Call:
Base URL https://api.mailpro.com/v2/email/add.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
NumberEmail Number of emails inserted
EmailUpdated If Force parameter is 2: number of emails updated
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
< NumberEmail >2569</ NumberEmail >
< EmailUpdated >458</ EmailUpdated >
</mailproapi>
12
ADD SINGLE EMAIL EMAIL
Description: Add one email
Method: Post
Call:
Base URL https://api.mailpro.com/v2/email/addSingle.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Email address
Email YES
Field1 NO Additional info
Field2 NO Additional info
Field3 NO Additional info
Result attributes:
Name Description
NumberEmail Number of emails inserted
EmailUpdated If Force parameter is 2: number of emails updated
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
< NumberEmail >2569</ NumberEmail >
< EmailUpdated >458</ EmailUpdated >
</mailproapi>
13
DELETE SINGLE EMAIL EMAIL
Description: Delete an email
Method: Post
Call:
Base URL https://api.mailpro.com/v2/email/del.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Result Result of action
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Result>OK</Result>
</mailproapi>
14
EDIT EMAIL EMAIL
Description: Update an email with new values
Method: Post
Call:
Base URL https://api.mailpro.com/v2/email/edit.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
...
Result attributes:
Name Description
Email[] Identify the Email
IdEmail ID of the Email
Email New Email
Field1 New Field1
...
Field25 New Field25
15
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Email>
<IdEmail>78485</IdEmail>
<Email>test2@test,com</Email>
<Field1>name</Field1>
<Field2>first name</Field2>
<Field25>street</Field25>
</Email>
</mailproapi>
16
LIST MESSAGES EMAIL
Description: Get a listing of all Messages
Method: Get
Call:
Base URL https://api.mailpro.com/v2/message/list.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Messages[] Contains list of messages
Message[] Identify each message
MessageId ID of the message
Creation Date of message (or last modification date)
CreationDate
Format : YYYY-MM-DDThh:mm:ss (ISO format)
Subject Subject of message
BodyHTML HTML of message encode
Language Language of message
LinkAlign Alignment of text
1 show the top text
LinkUp
0 hide the top text
17
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Messages>
<Message>
<MessageId>5025</MessageId>
< CreationDate >2012-01-02T01:00:00</ CreationDate >
<Subject> My Message </Subject>
<BodyHTML>HTML encode code</BodyHTML>
<Language>EN</Language>
<LinkAlign>center</LinkAlign>
<LinkUp>1</LinkUp>
</Message>
</Messages>
</mailproapi>
18
ADD MESSAGE EMAIL
Description: Add a new message (Maximum 100 Messages)
Method: Post
Call:
Base URL https://api.mailpro.com/v2/message/add.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
LinkAlign YES Where the automatic link are align (center, left, right)
Result attributes:
Name Description
Message[] Identify the message
MessageId ID of the message
Creation Date of message (or last modification date)
CreationDate
Format : YYYY-MM-DDThh:mm:ss (ISO format)
Subject Subject of message
BodyHTML HTML Body of message
Language Language of message
LinkAlign alignment of text
1 show the top text
LinkUp
0 hide the top text
19
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Message>
<MessageId>5025</MessageId>
<CreationDate>2012-01-02T01:00:00</CreationDate>
<Subject> My Message </Subject>
<BodyHTML>HTML CODE</BodyHTML>
<Language>EN</Language>
<LinkAlign>center</LinkAlign>
<LinkUp>1</LinkUp>
</Message>
</mailproapi>
20
DELETE MESSAGE EMAIL
Description: Delete a message
Method: Post
Call:
Base URL https://api.mailpro.com/v2/message/del.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Result Result of action
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Result>OK</Result>
</mailproapi>
21
EDIT MESSAGE
EMAIL
Description: Edit a message
Method: Post
Call:
Base URL https://api.mailpro.com/v2/message/edit.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Message[] Identify the message
MessageId ID of the message
Creation Date of message (or last modification date)
CreationDate
Format : YYYY-MM-DDThh:mm:ss (ISO format)
Subject Subject of message
BodyHTML HTML Body of message
Language Language of message
LinkAlign alignment of text
1 show the top text
LinkUp
0 hide the top text
22
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Message>
<MessageId>5025</MessageId>
<CreationDate>2012-01-02T01:00:00</CreationDate>
<Subject> My Message </Subject>
<BodyHTML>HTML CODE</BodyHTML>
<Language>EN</Language>
<LinkAlign>center</LinkAlign>
<LinkUp>1</LinkUp>
</Message>
</mailproapi>
23
CAMPAIGN LIST
EMAIL
Description: Get a listing of schedule mailing.
Method: Get
Call:
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Sends[] Contains list of Sends
Send Identify each Send
IDSend ID of the Send
AddressBookID ID of address book
UnsubscribeAddressBookID ID of unsubscribe address book
IDCampaign ID of campaign (is null if they don’t have campaign)
SenderName Name of sender
SenderEmail Email of sender
Date of schedule Send
DatePlanned Format : YYYY-MM-DDThh:mm:ss (ISO format)
SubjectMessage Subject of Message
BodyHTML HTML of schedule Send
NumberCredit Required number of credit for this Send
24
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<sends>
<send>
< IDSend >5025</ IDSend >
< AddressBookID>5025</ AddressBookID>
< UnsubscribeAddressBookID>854</ UnsubscribeAddressBookID>
< IDCampaign >5025</ IDCampaign >
< SenderName >Jean dupont</ SenderName >
< SenderEmail >jean@gmail.com</ SenderEmail >
< DatePlanned >2012-01-02T01:00:00</ DatePlanned >
< SubjectMessage >Hello world!</ SubjectMessage >
< BodyHTML >”<html><body>Hello world!</body></html>”</ BodyHTML >
<NumberCredit>1205</ NumberCredit >
</send>
</ sends >
</mailproapi>
25
DELETE CAMPAIGN EMAIL
Description: Delete a scheduled campaign
Method: Post
Call:
Base URL https://api.mailpro.com/v2/send/del.xml
Parameters
Name Mandatory Description
Result attributes:
Name Description
Result Result of action
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Result>OK</Result>
</mailproapi>
26
ADD CAMPAIGN EMAIL
Description: Add a campaign to send at a scheduled time.
Method: Post
Call:
Base URL https://api.mailpro.com/v2/send/add.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Send Identify each Send
IDSend ID of the Send
AddressBookID ID of addressBook
UnsuscribeAddressBookID ID of unsubscribe address book
IDCampaign ID of campaign (is null if they don’t have campaign)
SenderName Name of sender
SenderEmail Email of sender
Date of schedule Send
DatePlanned Format : YYYY-MM-DDThh:mm:ss (ISO format)
SubjectMessage Subject of Message
BodyHTML HTML of schedule Send
NumberCredit Required number of credit for this Send
27
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<send>
< IDSend >5025</ IDSend >
< AddressBookID>5025</ AddressBookID>
< UnsubscribeAddressBookID>854</ UnsubscribeAddressBookID>
< IDCampaign >5025</ IDCampaign >
< SenderName >Jean dupont</ SenderName >
< SenderEmail >jean@gmail.com</ SenderEmail >
< DatePlanned >2012-01-02T01:00:00</ DatePlanned >
< SubjectMessage >Hello world!</ SubjectMessage >
< BodyHTML >”<html><body>Hello world!</body></html>”</ BodyHTML >
<NumberCredit>1205</ NumberCredit >
</send>
</mailproapi>
28
SEND ONE EMAIL ONLY EMAIL
Description: Send an email only to one email, no address book needed.
Method: Post
Call:
Base URL https://api.mailpro.com/v2/send/addSingle.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
SingleSend The email sent
IdSingleSend ID of the single send
IdEmailExp Sender email address ID
DatePlanned Date of scheduled send
Subject Subject of message
BodyHTML HTML content encode
Email Recipient email address
Field1 Field1
Field2 Field2
29
Field3 Field3
....
Field25 Field25
UnsubscriptionLink Include unsubscription link or not
EmailReply Optional email address used for reply
ActivateStatistics Activate statistics or not (tracking links)
Example of result:
30
SEND ONE EMAIL ONLY EMAIL
Description: Send an email only to one email, no address book needed.
Method: Post
Call:
Base URL https://api.mailpro.com/v2/send/addSingle2.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Email address
Email YES
Field1 NO Additional info
Field2 NO Additional info
Field3 NO Additional info
Result attributes:
Name Description
SingleSend The email sent
IdSingleSend ID of the single send
IdEmailExp Sender email address ID
DatePlanned Date of scheduled send
31
Subject Subject of message
BodyHTML HTML content encode
Email Recipient email address
Field1 Field1
Field2 Field2
Field3 Field3
....
Field25 Field25
UnsubscriptionLink Include unsubscription link or not
EmailReply Optional email address used for reply
ActivateStatistics Activate statistics or not (tracking links)
Example of result:
</mailproapi>
32
SEND TEST EMAIL EMAIL
Description: Send a test message.
Method: Post
Call:
Base URL https://api.mailpro.com/v2/send/sendingTest.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
SendingTest The test email sent
IdSendingTest ID of the sending test
ToEmail Recipient’s email
FromEmail Sender’s email
SenderName Name of the sender
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<SendingTest>
<IdSendingTest>1</IdSendingTest>
<ToEmail>sender2@example.com</ToEmail>
<FromEmail>sender2@example.com</FromEmail>
<SenderName>Second Sender222222</SenderName>
</SendingTest>
</mailproapi>
33
LIST TRANSACTIONAL EMAIL EMAIL
Description: Get a listing of all Transactional Messages
Method: Get
Call:
Base URL https://api.mailpro.com/v2/transactionalEmail/list.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
TransactionalEmails[] Contains list of transactional messages
TransactionalEmail[] Identify each transactional message
Id ID of the transactional message
MessageId ID of the message
Name Name of the transactional message
UpdateDate Update date
FolderId Folder Id
Status (1: Enabled
Enabled
0: Disabled)
Event type (0: Date in address book field
EventType 1: Event in address book
2: After email sent)
For event type 0 and 1: Address book Id
EventMetadata1
For event type 2: Campaign Id
For event type 0: Field number
EventMetadata2 For event type 1: “Subscribed”/”Unsubscribed”
For event type 2: Condition
For event type 0: Date format
EventMetadata3 For event type 1: NA (not applied)
For event type 2: Type
For event type 0: Date format separator
EventMetadata4 For event type 1: NA (not applied)
For event type 2: Link in message
34
For event type 0: Time format
EventMetadata5 For event type 1: NA (not applied)
For event type 2: NA (not applied)
For event type 0: Date mode (“0”: Send immediately / “1”: Next occurrence of the date (one time
only) / “2”: All next occurrences of the date (anniversary) / “3”: Do not send if date in past)
EventMetadata6
For event type 1: NA (not applied)
For event type 2: NA (not applied)
Color Color
Subject Subject
ExpEmailId Sender Email Id
ExpEmailReplyId Reply to Email Id
UnsubscribeListId Id of unsubscribe address book
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<TransactionalEmails>
<TransactionalEmail>
<Id>50654</Id>
<MessageId>5025</MessageId>
<Name>My Name</Name>
<UpdateDate>2012-01-02T01:00:00</UpdateDate>
<FolderId>580</FolderId>
<Enabled>1</Enabled>
<EventType>2</EventType>
<EventMetadata1>1011545</EventMetadata1>
<EventMetadata2>1</EventMetadata2>
<EventMetadata3>dd*MM*yyyy</EventMetadata3>
<EventMetadata4>.</EventMetadata4>
<EventMetadata5>HH:mm:ss</EventMetadata5>
<EventMetadata6>2</EventMetadata6>
<Color>#bdbdbd</Color>
<Subject> My Message </Subject>
<ExpEmailId>342</ExpEmailId>
<ExpEmailReplyId>4334</ExpEmailReplyId>
<UnsubscribeListId>5646</UnsubscribeListId>
<NumberOfDays>22</NumberOfDays>
<Time>09:44:00.0000000</Time>
</TransactionalEmail>
</TransactionalEmails>
</mailproapi>
35
ADD NEW TRANSACTIONAL MESSAGE EMAIL
Description: Add a new transactional message
Method: Post
Call:
Base URL https://api.mailpro.com/v2/transactionalEmail/add.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
YES For event type 0: Date format separator (“.” / ”-” / ”/” / ” ” / ””)
EventMetadata4 NO For event type 1: NA (not applied)
YES (Only if For event type 2: Link in message (“*” for all)
Type is “Clicked”)
EventMetadata5 YES For event type 0: Date contains time (“1” for True / “0” for False)
36
For event type 1: NA (not applied)
For event type 2: NA (not applied)
For event type 0: Date modes (“0”: Send immediately / “1”: Next occurrence of
the date (one time only) / “2”: All next occurrences of the date (anniversary) / “3”: Do not
EventMetadata6 YES send if date in past)
For event type 1: NA (not applied)
For event type 2: NA (not applied)
Time NO The time for deliver the message, only if Immediately is False
Result attributes:
Name Description
TransactionalEmail[] Identify the transactional message
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<TransactionalEmail >
<Id>5025</Id>
</ TransactionalEmail >
</mailproapi>
37
DELETE TRANSACTIONAL EMAIL EMAIL
Description: Delete a transactional message
Method: Post
Call:
Base URL https://api.mailpro.com/v2/transactionalEmail/del.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Result Result of action
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Result>OK</Result>
</mailproapi>
38
EDIT TRANSACTIONAL MESSAGE
EMAIL
Description: Edit a transactional message
Method: Post
Call:
Base URL https://api.mailpro.com/v2/transactionalEmail/edit.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
YES For event type 0: Date format separator (“.” / ”-” / ”/” / ” ” / ””)
EventMetadata4 NO For event type 1: NA (not applied)
YES (Only if For event type 2: Link in message (“*” for all)
Type is
“Clicked”)
39
For event type 0: Date contains time (“1” for True / “0” for False)
EventMetadata5 YES For event type 1: NA (not applied)
For event type 2: NA (not applied)
For event type 0: Date modes (“0”: Send immediately / “1”: Next
occurrence of the date (one time only) / “2”: All next occurrences of the date
EventMetadata6 YES (anniversary) / “3”: Do not send if date in past)
For event type 1: NA (not applied)
For event type 2: NA (not applied)
Time NO The time for deliver the message, only if Immediately is False
Result attributes:
Name Description
Result Result of action
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Result>OK</Result>
</mailproapi>
40
UPDATE TRANSACTIONAL EMAIL STATUS EMAIL
Description: Change the status (enabled/disabled) of a transactional message
Method: Post
Call:
Base URL https://api.mailpro.com/v2/transactionalEmail/setStatus.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Result Result of action
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Result>OK</Result>
</mailproapi>
41
LIST HISTORIC SENDING EMAIL
Description: Get a list of sending historic
Method: Get
Call:
Base URL https://api.mailpro.com/v2/historic/list.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Histories[] Contains list of Historics
Historic Identify each Historic
IDHistoric ID of the Historic
Date of Mailing was send
DateOfMailing
Format : YYYY-MM-DDThh:mm:ss (ISO format)
SubjectMessage Subject of Message
AddressBookID ID of address book
IDCampaign ID of campaign (is null if they don’t have campaign)
BodyHTML HTML of Mailing
NumberCredit Required number of credit for this Mailing
42
Example of result :
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Histories>
<Historic>
< IDHistoric >5025</ IDHistoric >
< DateOfMailing >2012-01-02T01:00:00</ DateOfMailing >
< SubjectMessage >Hello world!</ SubjectMessage >
< AddressBookID >12456</ AddressBookID >
< IDCampaign >12456</ IDCampaign >
< BodyHTML >”<html><body>Hello world!</body></html>”</ BodyHTML >
43
LIST EMAIL SENDER EMAIL
Description: Get a listing of email sender.
Method: Get
Call:
Base URL https://api.mailpro.com/v2/senderEmail/list.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
ExpEmails[] Contains list of Sender email
ExpEmail Identify each Sender email
ExpEmailId ID of the email sender
Date of creation
CreationDate
Format : YYYY-MM-DDThh:mm:ss (ISO format)
SenderName Sender Name
Email Email sender
IsValid True if valid or false if invalid
44
Example of result :
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<ExpEmails>
<ExpEmail>
<ExpEmailId>5025</ExpEmailId>
<CreationDate>2012-01-02T01:00:00</CreationDate>
< SenderName >Dupont Jean</ SenderName >
< Email>Dupont.Jean@gmail.com</ Email >
< IsValid>true</ Valid >
</ExpEmail>
</ExpEmails >
</mailproapi>
45
DELETE EMAIL SENDER
EMAIL
Description: Delete email sender.
Method: Post
Call:
Base URL https://api.mailpro.com/v2/senderEmail/del.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Result Result of action
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Result>OK</Result>
</mailproapi>
46
STATISTICS: LIST CAMPAIGN
EMAIL
Description: Get a listing of campaign.
Method: Get
Call:
Base URL https://api.mailpro.com/v2/stats/list.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Campaigns[] Contains list of Campaign
Campaign Identify each Campaign
IdCampaign ID of the Historic
Date of Mailing was send
DateCampaign
Format : YYYY-MM-DDThh:mm:ss (ISO format
TitleCampaign Title of Campaign
NumberEmailSend Number of emails send
NumberEmailOpen Number of opening
NumberEmailClick Number of click
BadMail Number of badmail
47
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Campaigns>
<Campaign>
< IdCampaign >5025</ IdCampaign >
< DateCampaign >2012-01-02T01:00:00</ DateCampaign >
< TitleCampaign >Hello world!</ TitleCampaign >
< NumberEmailSend>1205</ NumberEmailSend >
< NumberEmailOpen >600</ NumberEmailOpen >
< NumberEmailClick >35</ NumberEmailClick >
< BadMail >25</ BadMail >
</Campaign>
</ Campaigns >
</mailproapi>
48
STATISTICS: DELETE CAMPAIGN EMAIL
Description: Delete a Campaign
Method: Post
Call:
Base URL https://api.mailpro.com/v2/stats/del.xml
Parameters
Name Mandatory Description
Result attributes:
Name Description
Result Result of action
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Result>OK</Result>
</mailproapi>
49
GET SENT MESSAGES BY HOUR
EMAIL
Description: Get Open and click by hour
Method: Get
Call:
Base URL https://api.mailpro.com/v2/stats/byHour.xml
Parameters
Name Mandatory Description
Result attributes:
Name Description
Hours[] Identify each Campaign
Hour[] List of hour and day
Value of hour and day
Value
Format : YYYY-MM-DDThh:mm:ss (ISO format)
NumberEmailOpen Sum of open for this hour
NumberEmailClick Sum of click for this hour
50
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Hour>
<value>2012-01-02T01:00:00</value>
< NumberEmailOpen >12</ NumberEmailOpen >
< NumberEmailClick >2</ NumberEmailClick >
</Hour>
<Hour>
<value>2012-01-02T02:00:00</value>
< NumberEmailOpen >32</ NumberEmailOpen >
< NumberEmailClick >12</ NumberEmailClick >
</Hour>
<Hour>
<value>2012-01-02T04:00:00</value>
< NumberEmailOpen >0</ NumberEmailOpen >
< NumberEmailClick >0</ NumberEmailClick >
</Hour>
</mailproapi>
51
GET SENT MESSAGES BY DAY EMAIL
Description: Get Open and click by hour
Method: Get
Call:
Base URL https://api.mailpro.com/v2/stats/byDay.xml
Parameters
Name Mandatory Description
Result attributes:
Name Description
Days[] List of day
Day Each day
Value of day
Value
Format : YYYY-MM-DDThh:mm:ss (ISO format)
NumberEmailOpen Sum of open for this day
NumberEmailClick Sum of click for this day
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Days>
<Day>
<value>2012-01-01T00:00:00</value>
< NumberEmailOpen >12</ NumberEmailOpen >
< NumberEmailClick >2</ NumberEmailClick >
</ Day >
< Day >
<value>2012-01-02T00:00:00</value>
< NumberEmailOpen >32</ NumberEmailOpen >
< NumberEmailClick >12</ NumberEmailClick >
</ Day >
< Day >
<value>2012-01-04T00:00:00</value>
< NumberEmailOpen >0</ NumberEmailOpen >
< NumberEmailClick >0</ NumberEmailClick >
</ Day >
</Days>
</mailproapi>
52
GET OPENED MESSAGES EMAIL
Description: Get Open Emails for a Campaign
Method: Get
Call:
Base URL https://api.mailpro.com/v2/stats/open.xml
Parameters
Name Mandatory Description
Result attributes:
Name Description
ListUsers[] List of users who opened the mailing
User[] User Detail
EmailID ID of the Email
Email Email
DateOpen Date of client open the email
IdAddressBook Address book Id
AddressBookTitle Address book title
53
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<ListUsers >
<User>
<EmailID>1025</EmailID>
<Email>test@test,com</Email>
<DateOpen>12.12.2012</DateOpen>
<IDAddressBook>2012</IDAddressBook>
<AddressBookTitle>Title</AddressBookTitle>
</User>
<User>
<EmailID>1023</EmailID>
<Email>test@test,com</Email>
<DateOpen>10.12.2012</DateOpen>
<IDAddressBook>2012</IDAddressBook>
<AddressBookTitle>Title</AddressBookTitle>
</User>
</ListUsers>
</mailproapi>
54
LINKS CLICKED OF A CAMPAIGN EMAIL
Description: Get Click link for a Campaign
Method: Get
Call:
Base URL https://api.mailpro.com/v2/stats/click.xml
Parameters
Name Mandatory Description
Result attributes:
Name Description
ListUsers[] List of users who opened the mailing
User User Detail
EmailID ID of the Email
Email Email
DateClick Date of client click the link
URL Url of click
55
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<ListUsers >
<User>
<EmailID>1025</EmailID>
<Email>test@test,com</Email>
<DateOpen>12.12.2012</DateOpen>
< URL> www.google.com</URL >
</User>
<User>
<EmailID>1023</EmailID>
<Email>test@test,com</Email>
<DateOpen>10.12.2012</DateOpen>
< URL> www.google.com</URL >
</User>
</ListUsers>
</mailproapi>
56
STATISTICS : USER SYSTEM EMAIL
Description: Get list of operating system when the user opened
Method: Get
Call:
Base URL https://api.mailpro.com/v2/stats/system.xml
Parameters
Name Mandatory Description
Result attributes:
Name Description
ListSystem[] List of OS
System Operating System
Name Name of OS
NumberEmail Number of opening with this OS
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
< ListSystem >
< System >
< Name >Windows XP</ Name >
< NumberEmail >52</ NumberEmail >
</ System >
< System >
< Name >Android</ Name >
< NumberEmail >401</ NumberEmail >
</ System >
< System >
< Name > Windows Phone</ Name >
< NumberEmail >41</ NumberEmail >
</ System >
</ListUsers>
</mailproapi>
57
STATISTICS: EMAIL SOFTWARE EMAIL
Description: Get list of email software or webmail when the user opened
Method: Get
Call:
Base URL https://api.mailpro.com/v2/stats/emailSoftware.xml
Parameters
Name Mandatory Description
Result attributes:
Name Description
ListEmailSoftware[] List of Email Software
EmailSoftware[] Email Software
EmailSoftware Name of Email Software or webmail (site)
NumberEmail Number of email
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
< ListEmailSoftware >
< EmailSoftware >
<EmailSoftware>Gmail</EmailSoftware>
<NumberEmail>52</NumberEmail>
</EmailSoftware>
<EmailSoftware>
<EmailSoftware>Windows live</EmailSoftware>
<NumberEmail>102</NumberEmail>
</EmailSoftware>
<EmailSoftware>
< EmailSoftware > Outlook </ EmailSoftware >
< NumberEmail >105</ NumberEmail >
</EmailSoftware>
<EmailSoftware>
< EmailSoftware > Mail Mac </ EmailSoftware >
< NumberEmail >501</ NumberEmail >
</EmailSoftware>
</ListEmailSoftware>
</mailproapi>
58
STATISTICS: BY COUNTRY EMAIL
Description: Get list of country when the user opened
Method: Get
Call:
Base URL https://api.mailpro.com/v2/stats/country.xml
Parameters
Name Mandatory Description
Result attributes:
Name Description
ListCountry[] List of Countries
Country[] Country
Name Name of country
Code ISO 2 char country code
NumberEmail Number of email
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
< ListCountry >
< Country >
< Name > SWITZERLAND</ Name >
< Code > CH</ Code >
< NumberEmail >52</ NumberEmail >
</ Country >
< Country >
< Name > POLAND</ Name >
< Code > PL</ Code >
< NumberEmail >123</ NumberEmail >
</ Country >
< Country >
< Name > UNITED KINGDOM</ Name >
< Code > UK</ Code >
< NumberEmail >123</ NumberEmail >
</ Country >
</ ListCountry >
</mailproapi>
59
STATISCTICS: BADMAIL EMAIL
Description: Get list of bad mails for selected campaign
Method: Get
Call:
Base URL https://api.mailpro.com/v2/stats/badMail.xml
Parameters
Name Mandatory Description
Result attributes:
Name Description
ListBadMail[] List of Bad mails
BadMail[] Bad mail
Email Email address
Date The date the bad mail was detected
Error The reason the email was filtered
AddressBookId The address book where the email was stored
60
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
< ListBadMail >
< BadMail>
< Email > badmail@example.com</ Email >
< Date > 2014-02-11T17:16:00</ Date >
< Error >bad-mailbox: 5.1.1 (bad destination mailbox address)</ Error >
< AddressbookId >1026</ AddressbookId >
</ BadMail>
< BadMail>
< Email > badmail2@example.com</ Email >
< Date > 2014-02-11T17:16:00</ Date >
< Error >bad-mailbox: 5.1.1 (bad destination mailbox address)</ Error >
< AddressbookId >1026</ AddressbookId >
</ BadMail>
</ ListBadMail >
</mailproapi>
61
CREDITS ACCOUNT
Description: Get the remain credits for a client
Method: Post
Call:
Base URL https://api.mailpro.com/v2/account/credits.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Credit Number of remained credits
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Credit>2500</Credit>
</mailproapi>
62
ACCOUNT: SUBSCRIPTION END DATE EMAIL
Description: Get the subscription end date for a client
Method: Post
Call:
Base URL https://api.mailpro.com/v2/account/subscriptionEndDate.xml
Parameters
Name Mandatory Description
ApiKey YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
SubscriptionEndDate Subscription end date
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<SubscriptionEndDate>2017-09-04 23:31:33.380</SubscriptionEndDate>
</mailproapi>
63
PHP Code Example
Add an address book, a mail and a message, get ID expeditor email and send the mail
<?php
$IDClient = 'Your Customer ID';
$APIKey = 'Your API Key'; #On demand
$Message = '<html><head></head><body>Send from API</body></html>';
$Subject = 'Send from API with PHP';
$email = 'example@mailpro.com,,,,,,,,,,,,,,,,,,,,,,,,,';
$CarnetName = 'Name of the AddressBook';
function addAddressBook($IDClient,$APIKey,$Title,$Type) {
$urlAdd = 'https://api.mailpro.com/v2/addressbook/add.xml';
$post = array(
'APIKey' => $APIKey,
'Title' => $Title,
'IDClient' => $IDClient,
'Type' => $Type );
$tagName = 'AddressBookId';
return sendPostData($urlAdd, $post,$tagName);
}
function addEmail($APIKey,$AddressBookId,$IDClient,$EmailList) {
$urlAdd = 'https://api.mailpro.com/v2/email/add.xml';
$post = array(
'APIKey' => $APIKey,
'AddressBookId' => $AddressBookId,
'IDClient' => $IDClient,
'emailList' => $EmailList );
$tagName ='NumberEmail';
return sendPostData($urlAdd, $post,$tagName);
}
function addMessage($IDClient,
$APIKey,$Subject,$BodyHTML,$Language,$linkAlign,$LinkUp){
$urlAdd = 'https://api.mailpro.com/v2/message/add.xml';
$post = array(
'IDClient' => $IDClient,
'APIKey' => $APIKey,
'Subject' => $Subject,
'BodyHTML' => $BodyHTML,
'Language' => $Language,
'linkAlign' => $linkAlign,
'LinkUp' => $LinkUp );
$tagName = 'MessageId';
return sendPostData($urlAdd, $post,$tagName);
}
function getListOfEmailSenders($APIKey,$IDClient) {
64
$urlAdd = 'https://api.mailpro.com/v2/senderEmail/list.xml';
$post = array(
'APIKey' => $APIKey,
'IDClient' => $IDClient );
$tagName = 'ExpEmailId';
return sendPostData($urlAdd, $post,$tagName);
}
function addSend($IDClient,$APIKey,$AddressBookId,$IDMessage,$IDEmailExp,$Campaign)
{
$urlAdd = 'https://api.mailpro.com/v2/send/add.xml';
$post = array(
'IDClient' => $IDClient,
'APIKey' => $APIKey,
'IDAddressBook' => $AddressBookId,
'IDMessage' => $IDMessage,
'IDEmailExp'=> $IDEmailExp,
'Campaign' => $Campaign );
$tagName = 'IDSend';
return sendPostData($urlAdd, $post,$tagName);
}
function sendPostData($urlAdd, $post,$tagName){
$ch = curl_init($urlAdd);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$resultat = curl_exec($ch);
$xml = new DomDocument('1.0');
$xml->loadXML($resultat);
$element = $xml->getElementsByTagName($tagName);
return $element ->item(0)->nodeValue;
}
?>
65
ASP.Net Code Example
Add an address book, a mail and a message, get ID expeditor email and send the mail
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Xml.XPath;
using System.Text;
using System.Xml;
namespace test
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string ApiKey = "Your API Key"; //On demand
string IDClient = "Your Customer ID";
string MessageBody = "<html><head></head><body>Send from API</body></html>";
string Subject = "Send from API with ASP.NET";
string email = "example@mailpro.com,,,,,,,,,,,,,,,,,,,,,,,,,";
66
{
string postData = "APIKey=" + ApiKey + "&IDClient=" + IDClient +
"&AddressBookID=" + addressBookID + "&emailList=" + email;
string PostUrl = "https://api.mailpro.com/v2/email/add.xml?";
methodPost(postData,PostUrl );
}
public string AddMessage(string ApiKey, string IDClient, string Subject, string
MessageBody)
{
string PostTagValue = "//Message/MessageId";
string PostUrl = "https://api.mailpro.com/v2/message/add.xml";
string postData = "APIKey=" + ApiKey + "&IDClient=" + IDClient + "&Subject="
+ Subject + "&BodyHTML=" + MessageBody + "&Language=EN&linkAlign=center&LinkUp=1";
string IDMessage = methodPostReturn(PostTagValue,postData,PostUrl);
return IDMessage;
}
public void AddSend(string ApiKey, string IDClient, string messageID, string
IDEmailExp, string addressBookID)
{
string PostUrl = "https://api.mailpro.com/v2/send/add.xml";
string postData = "APIKey=" + ApiKey + "&IDClient=" + IDClient +
"&IDAddressBook=" + addressBookID + "&IDMessage=" + messageID + "&IDEmailExp=" +
IDEmailExp + "&Campaign=1";
methodPost(postData, PostUrl);
}
public string methodGet(string ApiKey, string IDClient, string TagValue, string
NodeValue, string apiUrl)
{
Uri address = new Uri(apiUrl);
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
request.Method = "GET";
request.ContentType = "application/xml";
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
string strOutputXml = reader.ReadToEnd();
XPathDocument doc = new XPathDocument(apiUrl);
XPathNavigator nav = doc.CreateNavigator();
XPathNodeIterator iter = (XPathNodeIterator)nav.Evaluate(TagValue);
while (iter.MoveNext())
{
Response.Write("" +
iter.Current.SelectSingleNode(NodeValue).Value + " <br />");
}
string myvalue = iter.Current.SelectSingleNode(NodeValue).Value;
return myvalue;
}
}
public void methodPost(string postData, string PostUrl)
{
WebRequest requestPost = WebRequest.Create(PostUrl);
requestPost.Method = "POST";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
requestPost.ContentType = "application/x-www-form-urlencoded";
requestPost.ContentLength = byteArray.LongLength;
67
Stream dataStream = requestPost.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse responsePost = requestPost.GetResponse();
Console.WriteLine(((HttpWebResponse)responsePost).StatusDescription);
dataStream = responsePost.GetResponseStream();
StreamReader readerPost = new StreamReader(dataStream);
string responseFromServer = readerPost.ReadToEnd();
readerPost.Close();
dataStream.Close();
responsePost.Close();
}
public string methodPostReturn(string PostTagValue, string postData, string PostUrl)
{
WebRequest requestPost = WebRequest.Create(PostUrl);
requestPost.Method = "POST";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
requestPost.ContentType = "application/x-www-form-urlencoded";
requestPost.ContentLength = byteArray.LongLength;
Stream dataStream = requestPost.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse responsePost = requestPost.GetResponse();
Console.WriteLine(((HttpWebResponse)responsePost).StatusDescription);
dataStream = responsePost.GetResponseStream();
StreamReader readerPost = new StreamReader(dataStream);
string responseFromServer = readerPost.ReadToEnd();
XmlDocument doc = new XmlDocument();
doc.LoadXml(responseFromServer);
XPathNavigator nav = doc.CreateNavigator();
XPathNavigator node = nav.SelectSingleNode(PostTagValue);
StringWriter sw = new StringWriter();
XmlTextWriter tx = new XmlTextWriter(sw);
doc.WriteTo(tx);
string str = node.ToString();
readerPost.Close();
dataStream.Close();
responsePost.Close();
return str;
}
}
}
68
Java Code Example
Add an address book, a mail and a message, get ID expeditor email and send the mail
package testapi;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
69
String TagName = "ExpEmail";
String TagValue = "ExpEmailId";
String content = getData(getUrl);
String IdExp = XmlRead(content, TagName, TagValue);
return IdExp;
}
public static void AddEmail(String APIKey,String idClient,String Email,String
AddressBookID) throws MalformedURLException, IOException,
ParserConfigurationException, SAXException{
String urlParameters =
"APIKey="+APIKey+"&IDClient="+idClient+"&emailList="+Email+"&AddressBookID="+Address
BookID;
String posturl = "https://api.mailpro.com/v2/email/add.xml?";
postData(posturl,urlParameters);
}
public static String AddMessage(String APIKey,String idClient,String BodyHtml,String
Subject)throws MalformedURLException, IOException, ParserConfigurationException,
SAXException, XPathExpressionException{
String urlParameters = "APIKey="+APIKey+"&IDClient="+idClient+"&BodyHTML="+
BodyHtml +"&Subject="+ Subject +"&Language=EN&linkAlign=center&LinkUp=1";
String posturl = "https://api.mailpro.com/v2/message/add.xml";
String TagName = "Message";
String TagValue = "MessageId";
String content = postData(posturl,urlParameters);
String IdMessage = XmlRead(content, TagName, TagValue);
return IdMessage;
}
public static void AddSend(String APIKey,String idClient,String IdExpediteur,String
AddressBookID,String MessageID )throws MalformedURLException, IOException,
ParserConfigurationException, SAXException{
String urlParameters =
"APIKey="+APIKey+"&IDClient="+idClient+"&IDAddressBook="+AddressBookID+"&IDMessage="
+MessageID+"&IDEmailExp="+IdExpediteur+"&campaign=1";
String posturl = "https://api.mailpro.com/v2/send/add.xml";
postData(posturl,urlParameters);
}
public static String getData (String getUrl) throws MalformedURLException,
IOException{
URL website = new URL(getUrl);
URLConnection connection = website.openConnection();
BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
String inputLine;
while ((inputLine = in.readLine()) != null)
response.append(inputLine);
in.close();
return response.toString();
}
public static String XmlRead(String content, String TagName, String TagValue) throws
XPathExpressionException, ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
DocumentBuilder b = f.newDocumentBuilder();
Document doc = b.parse(new ByteArrayInputStream(content.getBytes("UTF-8")));
NodeList nl = doc.getElementsByTagName(TagName);
70
Element element = (Element) nl.item(0);
Node Id = element.getElementsByTagName(TagValue).item(0);
String response = Id.getTextContent();
return response;
}
public static String postData(String posturl,String urlParameters) throws
IOException, ParserConfigurationException, SAXException{
URL url = new URL(posturl);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(urlParameters);
writer.flush();
String line;
StringBuffer answer = new StringBuffer();
BufferedReader reader = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
while ((line = reader.readLine()) != null) {
answer.append(line);
}
String response = answer.toString();
writer.close();
reader.close();
return response;
}
}
71
Visual Basic Code Example
Add an address book, a mail and a message, get ID expeditor email and send the mail
<%
idClient = "Your Customer ID"
APIkey = "Your API Key" 'On demand
email = "example@mailpro.com,,,,,,,,,,,,,,,,,,,,,,,,,"
message = "<html><head></head><body>Send from API</body></html>"
subject = "Send from API with Visual Basic"
AddressBookName = "Name of the AddressBook"
AddressBookID = addAddressBook(idClient,APIkey,AddressBookName)
addEmail AddressBookID, email, idClient, APIkey
MessageId = addMessage(idClient,APIkey,message,subject)
ExpID = getIdExp(idClient,APIkey)
addSend idClient,APIkey,AddressBookID,MessageId,ExpID
72
formdata = "IDClient="& idClient &"&APIKey=" & APIkey & "&IDAddressBook=" &
AddressBookID & "&IDMessage="& MessageId &"&IDEmailExp=" &ExpID & "&Campaign=1"
content = postData(url,formdata)
end function
public function postData(url,formdata)
Set oXmlhttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
lResolve =0
lConnect =0
lSend =0
lReceive =0
oXmlHttp.setOption 2, 13056
oXmlHttp.open "POST",url, false
oXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXmlhttp.setTimeouts lResolve, lConnect, lSend, lReceive
oXmlHttp.send formdata
responseTxt =Cstr(oXmlHttp.responseText)
Set oXmlHttp = nothing
postData = responseTxt
end function
public function returnValue(content,tagName,childTagName,nodeName)
Set objxml = Server.CreateObject("Microsoft.XMLDOM")
objxml.async = False
objxml.loadXML content
If objXML.parseError.errorCode <> 0 Then
ReportErrorXML(objXML)
End If
Response.ContentType = "text/html"
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CharSet = "UTF-8"
For Each xmlProduct In objXML.getElementsByTagName(tagName)
For Each xmladr In xmlProduct.getElementsByTagName(childTagName)
getContent =
xmladr.selectSingleNode(nodeName).text
next
Next
returnValue = getContent
end function
public function returnValue2(content,childTagName,nodeName)
Set objxml = Server.CreateObject("Microsoft.XMLDOM")
objxml.async = False
objxml.loadXML content
If objXML.parseError.errorCode <> 0 Then
ReportErrorXML(objXML)
End If
Response.ContentType = "text/html"
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CharSet = "UTF-8"
For Each xmladr In objXML.getElementsByTagName(childTagName)
getContent =
xmladr.selectSingleNode(nodeName).text
next
returnValue2 = getContent
end function
public function getGet(url)
Set oXmlhttp = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
73
lResolve =0
lConnect =0
lSend =0
lReceive =0
oXmlHttp.setOption 2, 13056
oXmlHttp.open "GET", url, false
oXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXmlhttp.setTimeouts lResolve, lConnect, lSend, lReceive
oXmlHttp.send
responseTxt = Cstr(oXmlHttp.responseText)
Set oXmlHttp = nothing
getGet = responseTxt
end function
public sub ReportErrorXML(objXML)
strErrText=""
Set xPE = objXML.parseError
With xPE
strErrText = "Your XML Document failed to load" & _
"due the following error." & vbCrLf & _
"Error #: " & .errorCode & ": " & xPE.reason & _
"Line #: " & .Line & vbCrLf & _
"Line Position: " & .linepos & vbCrLf & _
"Position In File: " & .filepos & vbCrLf & _
"Source Text: " & .srcText & vbCrLf & _
"Document URL: " & .url
End With
response.write strErrText
end sub
%>
74
LIST ADDRESSBOOK SMS
Description: Get a listing of all SMS Address Books
Method: Get
Call:
Base URL https://api.mailpro.com/sms/address_book/list.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
AddressBooks[] Contains list of address books
AddressBook[] Identify each address book
address_book_id ID of the address book
name Name of address book
total_number_phone Total of number phones in this address book
Example of result:
<api version="1">
<address_books>
<address_book>
<address_book_id>4254</address_book_id>
<name>FirstSms</name>
<total_number_phone>3</total_number_phone>
</address_book>
<address_book>
<address_book_id>4314</address_book_id>
<name>SecondList</name>
<total_number_phone>2</total_number_phone>
</address_book>
</address_books>
</api>
75
ADD ADDRESSBOOK SMS
Description: Add an address book (Maximum 100 Address Books)
Method: Post
Call:
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
AddressBooks[] Contains list of address books
AddressBookId ID of the address book
name Name of address book
Example of result:
76
DELETE ADDRESSBOOK SMS
Description: Delete an address Book
Method: Post
Call:
Base URL https://api.mailpro.com/sms/address_book/del.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Result Result of action
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<mailproapi version="1">
<Result>OK</Result>
</mailproapi>
77
EDIT ADDRESSBOOK SMS
Description: Edit an address Book
Method: Post
Call:
Base URL https://api.mailpro.com/sms/address_book/edit.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
AddressBook[] Identify the address book
Example of result:
<?xml version="1.0" encoding="utf-16" standalone="no"?>
<api version="1">
<address_book>
<address_book_id>4283</address_book_id>
<name>First_API</name>
<total_number_phone>3</total_number_phone>
</address_book>
</api>
78
LIST PHONE NUMBERS SMS
Description: Get a listing of all phone numbers in address book
Method: Get
Call:
Base URL https://api.mailpro.com/sms/phone/list.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Phones[] Contains list of address books
Phone[] Identify each address book
id_number Id of the phone number
number Phone number
firstname First name
lastname Last name
79
Example of result:
<api version="1">
<phones>
<phone>
<id_number>1777314</id_number>
<firstname>Jean</firstname>
<lastname>Dupont</lastname>
<number>0041791234545</number>
</phone>
<phone>
<id_number>1777425</id_number>
<firstname>Charle</firstname>
<lastname>Henry</lastname>
<number>0041791234540</number>
</phone>
</api>
80
ADD PHONE NUMBERS SMS
Description: Add one or more phone number
Method: Post
Call:
Base URL https://api.mailpro.com/sms/phone/add.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
result Result of action
Example of result:
<api version="1">
<phones>OK<phone>
</api>
81
DELETE PHONE NUMBER SMS
Description: Delete a phone number
Method: Post
Call:
Base URL https://api.mailpro.com/sms/phone/del.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
result Result of action
Example of result:
<api version="1">
<phones>OK<phone>
</api>
82
EDIT PHONE NUMBER SMS
Description: Update a phone number with new values
Method: Post
Call:
Base URL https://api.mailpro.com/sms/phone/edit.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
Phone[] Identify each address book
id_number Id of the phone number
number Phone number
firstname First name
lastname Last name
number New number
Example of result:
83
LIST SCHEDULE SMS SENDING SMS
Description: Get a listing of schedule send
Method: Get
Call:
Base URL https://api.mailpro.com/sms/send/list.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
sends[] Contains list of sends
send[] Identify each send
id_send Id of the send
scheduled_time Date of schedule send
message message
list_address_book List of address book for this send
charge Required number of credit for this send
Type of send:
type_to 0 addressbook list
1 single number
84
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<api version="1">
<sends>
<send>
<id_send>5025</id_send>
<scheduled_time>12.12.2012</scheduled_time>
<message>Hello world!</message>
<type_to>0</type_to>
<list_address_book>
<id_address_book>2506</id_address_book>
<id_address_book>2507</id_address_book>
</list_address_book>
< charge >1205</ charge >
</send>
</sends>
</api>
85
SEND SCHEDULE SMS SMS
Description: Add a schedule sending
Method: Post
Call:
Base URL https://api.mailpro.com/sms/send/add.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
sends[] Contains list of sends
send[] Identify each send
id_send Id of the send
scheduled_time Date of schedule send
message message
to List of address book for this send
charge Required number of credit for this send
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<api version="1">
<sends>
<send>
<id_send>5025</id_send>
<scheduled_time>12.12.2012</scheduled_time>
<message>Hello world!</message>
<to>
<id_address_book>2506</id_address_book>
<id_address_book>2507</id_address_book>
</to>
< charge >1205</ charge >
</send>
</sends>
</api>
86
DELETE SCHEDULE SMS SMS
Description: Delete a schedule SMS
Method: Post
Call:
Base URL https://api.mailpro.com/sms/send/del.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
result Result of action
Example of result:
<api version="1">
<result>OK</result >
</api>
87
SEND ONE SMS ONLY SMS
Description: Send an SMS without creating an address book
Method: Post
Call:
Base URL https://api.mailpro.com/sms/send/add_single.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
sends[] Contains list of sends
send[] Identify each send
id_send Id of the send
scheduled_time Date of schedule send
message message
to List of address book for this send
charge Required number of credit for this send
Example of result:
<?xml version='1.0' encoding='UTF-8'?>
<api version="1">
<sends>
<send>
<id_send>5025</id_send>
<scheduled_time>12.12.2012</scheduled_time>
<message>Hello world!</message>
<to> 0041796543221</to>
< charge >1.5</ charge >
</send>
</sends>
</api>
88
HISTORY SMS SENT SMS
Description: Get a list of sending (historic)
Method: Get
Call:
Base URL https://api.mailpro.com/sms/history/list.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
1 single number
Type NO
2 Address book
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
histories[] Contains list of historics
history[] Identify each historic
id_history Id of the historic
date_send Date of sms was send
message message
charge Required number of credit for this send
89
Example of result 1:
<?xml version='1.0' encoding='UTF-8'?>
<api version="1">
<histories>
<history>
<id_history>5025</id_history>
<date_send>12.12.2012</date_send>
<message>Hello world!</message>
< charge >1205</ charge >
<address_book_list>
<id_address_book>2506</id_address_book>
<phones>
<phone>
<id_number>1025</id_number>
<number>0041791234545</phone>
<Status>Jean</Status>
</phone>
</phones>
<id_address_book>2507</id_address_book>
</address_book_list>
</history>
</histories>
</api>
Example of result 2:
<?xml version='1.0' encoding='UTF-8'?>
<api version="1">
<histories>
<history>
<id_history>5026</id_history>
<date_send>12.12.2012</date_send>
<message>Hello world!</message>
<charge>1205</charge>
<number>0041796543210</number>
<status>1</status>
</history>
</histories>
</api>
90
GET SMS CREDITS SMS
Description: Get SMS credits of your account
Method: Get
Call:
Base URL https://api.mailpro.com/sms/credits/getcredits.xml
Parameters
Name Mandatory Description
api_key YES This is a GUID to identify the client and for access to the API
Result attributes:
Name Description
credits[] Contains list of purchases
Example of result
<?xml version='1.0' encoding='UTF-8'?>
<api version="1">
<credits>
< total_credit >1236</ total_credit >
</credits>
</api>
91