Messaging Application Programming Interface (MAPI)
is a messaging architecture and a Component Object Model based API for Microsoft
Windows. MAPI allows client programs to become (e-mail) messaging-enabled, MAPI
is designed to be independent of the protocol.
MAPI Protocol
doesn’t have recording option. We need
to write the cold manually.
Sessions can be run
as local or global sessions. If running as a global session, the Load runner
statements all finish with a suffix of _ex.
The logon statement is as follows for global session.
mapi_logon_ex(&mapi, "Logon",
"ProfileName=Default Outlook Profile",
"ProfilePass=",
Where ProfileName is “Outlook Profile Name” and
ProfilePass is “Password”
Prerequisites to
execute above statement.
Define mapi as ‘MAPI mapi = 0 before the logon statement.
Outlook profile should be created on the machine where we
are executing the script.
// Code to Send Mail.
mapi_send_mail_ex(&mapi,"SendMail",
"To=Recipient
Mail Address",
"Subject=Test
Mail",
"Body=
Test Mail!!! "
"
Body Text"
"Multiple
Lines",
"ATTACHMENTS",
"File=C:\\FileName", "ENDITEM",
LAST);
We
can also add CC and BCC above code if required.
Also
we can Perform Read Mail and Delete Mail actions.
While
executing the script a security message popup this causes execution of the
automation to stop.
Following
below steps we can overcome this issue.
Open
Outlook 2007
Click
on "Tools" and then "Trust
Center."
Click on the "Macro Security" link from the
left-hand pane.
Click on the check box next to "Warnings for signed macros; all unsigned macros are disabled" link and then Click on "Add-ins" to select it.
Click on the check box next to "Warnings for signed macros; all unsigned macros are disabled" link and then Click on "Add-ins" to select it.
Click on "Apply macro security settings to installed
add-ins" check box to adapt the disable security warnings settings from
the macros to include the add-ins as well. Click "OK" to close out of
all the dialog boxes. Close and reopen Microsoft Outlook for the changes to
take effect.