I must point out first that until three hours ago I hadn't used Delphi, and most of the code below is from a forum, so I apologise for my ignorance in advance.
The code compiles into a DLL which provides MAPI services for a Visual Basic email application. When MAPISendMail is triggered in this DLL it writes the name of the file being emailed into the Registry and broadcasts a message which my VB application picks up, and from there onwards can create an email. The code below works perfectly if the Windows user wants to email a single file, but if they choose to email several at once it only passes the first file they choose.
My question is how to deal with multiple files. Within the lpMessage structure the lpFiles parameter is supposed to be an array. However, I've tried different ways of processing it as an Array but they all cause the parent application to crash.
Ideally I'd like a solution that sets the Registry value "MAPISendMailFile" to be a semi-colon delimited list of files. (The code above omits the other MAPI functions which appear in the DLL but I don't think they're relevant to this problem).
Any help would be much appreciated.
- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
The code compiles into a DLL which provides MAPI services for a Visual Basic email application. When MAPISendMail is triggered in this DLL it writes the name of the file being emailed into the Registry and broadcasts a message which my VB application picks up, and from there onwards can create an email. The code below works perfectly if the Windows user wants to email a single file, but if they choose to email several at once it only passes the first file they choose.
My question is how to deal with multiple files. Within the lpMessage structure the lpFiles parameter is supposed to be an array. However, I've tried different ways of processing it as an Array but they all cause the parent application to crash.
Code:
uses
Windows
, MAPI
, REGISTRY
, SysUtils
;
function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal; var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal; stdcall;
implementation
function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal; var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal; stdcall;
Var MyReg : tregistry;
begin
MyReg:=Tregistry.create;
MyReg.rootkey:=HKEY_CURRENT_USER;
if MyReg.openkey('SOFTWARE\Apt\TCM\', true) then
begin
MyReg.writeString('MAPISendMailFile', lpMessage.lpFiles.lpszPathName);
MyReg.writeString('MAPISendMailSubject', lpMessage.lpszSubject);
MyReg.Closekey;
end;
MyReg.free;
SendMessage(65535, 50020, 10007, 0);
Result := SUCCESS_SUCCESS;
end;
Ideally I'd like a solution that sets the Registry value "MAPISendMailFile" to be a semi-colon delimited list of files. (The code above omits the other MAPI functions which appear in the DLL but I don't think they're relevant to this problem).
Any help would be much appreciated.
- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments