Home | Development | Partners | Resellers | About |
The Messaging API is a COM-like API that provides access to the contents of messaging stores. "Extended MAPI in Delphi" is a package providing access to Outlook-compatible objects through a COM-based API. Using MAPI, a program can connect to a MAPI store, and then perform operations against that store. |
Request # 8 How to use Personal folder (*.PST) files from DELPHI (Loading and Creating a *.PST) How with Extended MAPI a developer working on DELPHI can create or/and load a PST file without existing MAPI profile. Then you can use this *.PST as your Private Store, that hold secret data. Personal Information Stores - PST files - offers ideal opportunities for storing our correspondence in one place. This example will illustrate how to create/open PST files. In addition, we will illustrate how to copy/move/erase messages and folders. We chose to illustrate this here, since it is assumed that the PST file will not contain significant information and we may fidget with the data. We will show you how to implement the IMAPIProgress class that MAPI provides for the process visualization. With it you may, for instance, build an indicator that will show the process of copying 10 000 e-mails from one folder into another. The user will be able to monitor the process and will not be bored - something is "moving" there :-) Also:
ByRequest08EM as Compiled Application Source Code: In package |
Request # 9 How to get access to Exchange Public folders from DELPHI This example (By Request #9) will show you how to get access to public folders. This example requires connection with Exchange Server for efficient implementation. ByRequest09EM as Compiled Application Source Code: In package |
Request # 10 Extended MAPI DCOM NT Server as Service The idea behind this example is to implement a MAPI object that works as a COM Server in Windows NT Service. Our MAPI COM Server will perform basic things - LogOn, LogOff and will take all the messages from the Inbox folder. Start up parameters of this NT Service are PROFILENAME and PROFILEPASSWORD. We will also create a test client enabling us to check how our server works. Why do we need this example? For instance, you may create a perfectly normal DCOM client with DELPHI that uses Extended MAPI and is placed on some user's computer. This client may have connection to GAL for instance or to Contacts Folders through our NT Service. This may be for instance the Front Desk girl for whom we need to install an e-mail client or it may be used by the HR department for updating data. This NT Service may also be used by ASP pages through VB scripts. SvCom is an integrated package of classes and tools for development of service applications and use of NT Security framework. Currently SvCom components work with Delphi 4, 5, 6, 7 and 2005 and C++ Builder 5 and 6 under all flavors of Windows. ... procedure TMAPIActiveXService.ServiceBeforeInstall(Sender: TService); begin ServiceStartName := FindMySwitch('USERNAME', ['-', '/']); LogMessage(ServiceStartName, 0); Password := FindMySwitch('USERPASS', ['-', '/']); end; procedure TMAPIActiveXService.ServiceAfterInstall(Sender: TService); begin try RegAction := raReg; RegisterEXE; RegisterAsService(GUIDToString(CLASS_MAPICOMServer), self.Name); except on e: Exception do if e.Message <> '' then MessageBox(0, PChar(e.Message), 'MAPI ActiveX Service', MB_OK or MB_ICONERROR or MB_SERVICE_NOTIFICATION); else MessageBox(0, 'Can not install "MAPI ActiveX Service" service!', 'MAPI ActiveX Service', MB_OK or MB_ICONERROR or MB_SERVICE_NOTIFICATION); end; end; .... ByRequest10EM as Compiled Application Source Code: In package |
Request # 11 Get all available Message Stores in our MAPI Profile This example (By Request #11) will show you how to get access to all message stores listed in our MAPI profile. This includes also Delegated Mailbox. This example requires connection with Exchange Server for efficient implementation. ByRequest11EM as Compiled Application Source Code: In package |
Request # 12 Exchange ACL (Modifying Access Rights) Public Folders Access Control Access to Exchange server public folders is protected by custom mechanism. Although an object, which represents a folder in the Directory may have an associated Windows NT security descriptor with DACL in it, client access is controlled by an access control list of another kind. There is a bit of confusion here because both are called ACLs. The difference is that a Windows NT ACL specifies rights for Windows NT accounts, while a public folder ACL deals with MAPI PR_ENTRYIDs. I have a separate topic How NT Access Control Relates to Public Folder ACLs that describes where these two things come together. You can access public folder ACLs via either IExchangeFolderACLs interface, or IExchangeModifyTable. We have written a few samples that illustrate both approaches. Also, MSDN has a sample named ACLEDIT, which illustrates usage of IExchangeFolderACLs. Access Rights The following code fragment extracted from the Edk.pas file lists documented access rights. //Security bits const frightsReadAny = ULONG($0000001); frightsCreate = ULONG($0000002); frightsEditOwned = ULONG($0000008); frightsDeleteOwned = ULONG($0000010); frightsEditAny = ULONG($0000020); frightsDeleteAny = ULONG($0000040); frightsCreateSubfolder = ULONG($0000080); frightsOwner = ULONG($0000100); frightsContact = ULONG($0000200); rightsNone = ULONG($00000000); rightsReadOnly = frightsReadAny; rightsReadWrite = (frightsReadAny or frightsEditAny); rightsAll = ULONG($00001FB); The table below explains their meanings:
In addition to these rights Exchange server uses flag $0000400, which determines folder visibility to a user. This flag is not a member of rightsAll. Roles Microsoft Exchange server uses a few roles for public folder clients. Roles are convenient combinations of individual access rights. The following roles are defined:
You may easily determine which individual rights contribute to the role by examining it access mask. Who May Be Listed in an ACL? The following entities may be listed in a public folder ACL:
ByRequest12EM as Compiled Application Source Code: In package |
Request # 13 Out Of Office (Auto Replay Message, Message Rule) This step-by-step article describes how to create an out-of-office rule with Extended MAPI. How to:
This example requires connection with Exchange Server for efficient running. ByRequest13EM as Compiled Application Source Code: In package |
Request # 14 Outlook Folders (Inbox, Outbox, Sent Items, Deleted Items, Calendar, Contacts, Journal, Notes, etc...) This example (By Request #14) will show you how to get direct access to Microsoft Outlook specific folders as Calendar, Contacts, Notes, etc.. Example includes functions as:
ByRequest14EM as Compiled Application Source Code: In package |
Request # 15 Fast E-mail Agent Very often we receives a requests for a code by which a few lines written in Delphi can sent e-mail using Microsoft Exchange Server as e-mail server. This example covers exactly that. procedure TfrmMain.LogonAndSend; var StoreLogoffFlag:Cardinal; OutboxEntryID: TSBinary; ObjType:Cardinal; SentMailEID: PSPropValue; TempString:String; begin ZeroMemory(@OutboxEntryID, SizeOf(OutboxEntryID)); SentMailEID:=nil; // Init MAPI Subsystem hr:=MAPIInitialize(nil); if failed(hr) then raise Exception.Create(GetMAPIError(nil, hr)); try //Establish Session hr:=MAPILogonEx(Application.Handle, //Parent Window nil, //Profile name nil, //Profile password - newer used MAPI_EXTENDED or {/* Extended MAPI Logon */} MAPI_NEW_SESSION or {/* Don't use shared session */} MAPI_SERVICE_UI_ALWAYS or MAPI_ALLOW_OTHERS or {/* Make this a shared session */} MAPI_LOGON_UI, {/* Dialog box should be displayed */} FMAPISession); if failed(hr) then begin FMAPISession:=nil; raise Exception.Create(GetMAPIError(nil, hr)); end; // NOT NEED REALLY, BUT I LIKE TO KNOW MAPI VERSION StatusBar.SimpleText:=' MAPIVersion:' + GetMAPIVersion; //Get interface to Address Book hr := FMapiSession.OpenAddressBook(Self.Handle, nil, 0, FAddressBook); if failed(hr) then raise Exception.Create(GetMAPIError(FMapiSession, hr)); //Get interface to Mailbox hr := HrOpenExchangePrivateStore(FMapiSession, FMailbox); if failed(hr) then raise Exception.Create(GetMAPIError(FMapiSession, hr)); //Get Entry ID of Outbox folder hr := HrMAPIFindOutbox(FMailbox, OutboxEntryID.cb, PEntryID(OutboxEntryID.lpb)); if failed(hr) then raise Exception.Create(GetMAPIError(FMailbox, hr)); //Get Interface to Outbox folder hr := FMailbox.OpenEntry(OutboxEntryID.cb, PEntryID(OutboxEntryID.lpb), @IID_IMAPIFolder, MAPI_MODIFY or MAPI_NO_CACHE, ObjType, IUnknown(FOutbox)); if (MAPI_E_UNKNOWN_FLAGS = hr) then // Outlook Version < 2003 hr := FMailbox.OpenEntry(OutboxEntryID.cb, PEntryID(OutboxEntryID.lpb), @IID_IMAPIFolder, MAPI_MODIFY, ObjType, IUnknown(FOutbox)); if failed(hr) then raise Exception.Create(GetMAPIError(FMailbox, hr)); // Get Sent Items Folder - we will move message to this folder after submit // not mandatory - see below hr := HrGetOneProp(FMailbox, PR_IPM_SENTMAIL_ENTRYID, SentMailEID); if failed(hr) then raise Exception.Create(GetMAPIError(FMailbox, hr)); SentMailEID.ulPropTag := PR_SENTMAIL_ENTRYID; // Create a new empty message hr := FOutbox.CreateMessage(nil, 0, FMAPIMessage); if failed(hr) then raise Exception.Create(GetMAPIError(FOutbox, hr)); // Set Message Class hr:=HrMAPISetPropString(FMAPIMessage, PR_MESSAGE_CLASS, Pointer(PChar('IPM.Note'))); if failed(hr) then raise Exception.Create(GetMAPIError(FMAPIMessage, hr)); // Set Sent Items Entry ID - not mandatory hr:= HrSetOneProp(FMAPIMessage,SentMailEID); if failed(hr) then raise Exception.Create(GetMAPIError(FMAPIMessage, hr)); // Set Message Subject TempString:=Trim(ebSubject.Text); if TempString='' then TempString:='Test Message'; hr:=HrMAPISetPropString(FMAPIMessage, PR_SUBJECT, Pointer(PChar(TempString))); if failed(hr) then raise Exception.Create(GetMAPIError(FMAPIMessage, hr)); // Set Message Body TempString:=Trim(BodyMemo.Text); if Length(TempString)>254 then SetLargeBody else if Length(TempString)>0 then begin hr:=HrMAPISetPropString(FMAPIMessage, PR_BODY, Pointer(PChar(TempString))); if failed(hr) then raise Exception.Create(GetMAPIError(FMAPIMessage, hr)); end; //Set Recipients Resolve; // Save all changes hr := FMAPIMessage.SaveChanges(KEEP_OPEN_READWRITE); if failed(hr) then raise Exception.Create(GetMAPIError(FMAPIMessage, hr)); // Send Message hr := FMAPIMessage.SubmitMessage(0); if failed(hr) then raise Exception.Create(GetMAPIError(FMAPIMessage, hr)); ShowMessage('The message is going out...'); finally //Clear Sent Item Entry ID if Assigned(SentMailEID) then MAPIFreeBuffer(SentMailEID); //Clear Outbox EntryID if Assigned(OutboxEntryID.lpb) then MAPIFreeBuffer(OutboxEntryID.lpb); //Clear Outbox Interface FOutbox:=nil; //Clear Message Interface FMAPIMessage:=nil; FAddressBook:=nil; if Assigned(FMailbox) then begin StoreLogoffFlag:=LOGOFF_NO_WAIT; FMailbox.StoreLogoff(StoreLogoffFlag); FMailbox:=nil; end; if Assigned(FMAPISession) then FMAPISession.Logoff(Application.Handle, MAPI_LOGOFF_UI, 0); // always 0 FMAPISession:=nil; end; MAPIUnInitialize; end; ByRequest15EM as Compiled Application Source Code: In package |
Request # 16 DateTime restriction and Appointments This example shows how to construct DateTime restriction. With this restriction we will limit the listed Appointments to certain time interval. ByRequest16EM as Compiled Application Source Code: In package |
Request # 17 TClientDataSet & Extended MAPI This example shows how you can use TClientDataSet and Extended MAPI togeter. ByRequest17EM as Compiled Application Source Code: In package |
Request # 18 Signed Extended MAPI messages (digitally signed email) This example shows how you can decode digitally signed email. ByRequest18EM as Compiled Application Source Code: In package |
Request # 19 How to resolve display name to e-mail address and bind the Global Address List (GAL) to TClientDataSet/TDataSource/TDBNavigator/etc.. ByRequest19EM as Compiled Application Source Code: In package |
Request # 20 How to post/send an item to Microsoft Exchange Public Folder ByRequest20EM as Compiled Application This example shows how you can post/send an item to public folder, how to find and/or create a public folder, etc.. Source Code: In package |
Request # 21 How to Send an e-mail message on behalf of someone else ByRequest21EM as Compiled Application Send on Behalf will allow a user to send as another user while showing the recipient that it was sent from a specific user on behalf of another user. How to: - Displays the Outlook address book dialog box. - Performs name resolution, assigning entry identifiers to recipients in a recipient list. - use PR_SENT_REPRESENTING_XXXX properties Source Code: In package |
Request #
22 Command line .exe that sends e-mails ByRequest22EM as Compiled Application Parameters: T -> Recipients TO List C -> Recipients CC List S -> Message Subject B -> Message HTML Body (path to existing html file) A -> Attachments List (path to existing file) P –> MAPI/Outlook profile name U -> User SMTP e-mail address (existing exchange user) |
||
Usage (example):
CmdMail.exe -T="imibo@imibo.com, info@imibo.com, lolo@imibo.com" -P=Outlook -U="SMTP:az00008@mapisoft.com" -S="Test Message" -B="C:\Temp\Questions.htm" -A="C:\TEMP\SmtpClient.zip, C:\TEMP\TestFile.zip"
T -> Recipients TO List – each recipient should be delimited by comma.
Value is quoted (“)
code (snap): program CmdMail; Source Code: In package |
Request # 23 How to get and show the contact phones? ByRequest23EM as Compiled Application This example shows how you can get most of contact phones as: PR_ASSISTANT_TELEPHONE_NUMBER PR_BEEPER_TELEPHONE_NUMBER PR_BUSINESS_TELEPHONE_NUMBER PR_BUSINESS_FAX_NUMBER etc.. Source Code: In package |
Request # 24 How to build an address book dialog (Delphi way)? ByRequest24EM as Compiled Application Source Code: In package |
Request # 25 How to Open another person's Calendar folder and post an Appointment item? This example requires you to use a Microsoft Exchange account. The ability to open another person's folder, and whether or not you can change it, is controlled by the owner of the folder. ByRequest25EM as Compiled Application Source Code: In package |
||
Request # 26 How to Open another person's Task folder and post a Task item? This example requires you to use a Microsoft Exchange account. The ability to open another person's folder, and whether or not you can change it, is controlled by the owner of the folder. ByRequest26EM as Compiled Application Source Code: In package |
||
Request # 27 How to Open another person's Contact folder and post a Contact item? This example requires you to use a Microsoft Exchange account. The ability to open another person's folder, and whether or not you can change it, is controlled by the owner of the folder. ByRequest27EM as Compiled Application Source Code: In package |
||
Request # 28 How to Save (store) Meetings/Appointments item to DataBase and synchronize them (one way)? This example requires you to use a Microsoft Exchange account. ByRequest28EM as Compiled Application Source Code: In package |
||
Request # 29 How to spy for incoming messages where Subject contains "xxxxx" and move them to specific folder? This example requires you to use a Microsoft Exchange account. ByRequest29EM as Compiled Application Source Code: In package |
Request # 30 How to to add image to the mail body, not to add a image as an attachment (MAPI e-mail with embedded images)? ByRequest30EM as Compiled Application Source Code: not in package/by e-mail |
continue... |
Copyright © 2021 IMIBO |