Re: Emma
Originally posted by Samj
I've been playing around with this problem and I believe I may have a solution if you're still in need.
From the sample at:
http://www.global-shared.com/api/index.htm
Add:
&Scoped-define STRUCT-SIZE 24
DEFINE VARIABLE ndx AS INTEGER NO-UNDO.
DEFINE VARIABLE num-structs AS INTEGER NO-UNDO.
Modify:
DEFINE VARIABLE RecipNamePtr AS MEMPTR EXTENT 10. /* or whatever the limit is */
/* -----Build Recipient details ----- */
SET-SIZE(RecipDescPtr) =
(25 * NUM-ENTRIES(RecipName,";")).
DO ndx = 1 TO NUM-ENTRIES(RecipName,";"):
SET-SIZE(RecipNamePtr[ndx]) = LENGTH(ENTRY(ndx,RecipName,";")) + 1.
/* maximum = 255 */
PUT-STRING(RecipNamePtr[ndx],1) = ENTRY(ndx,RecipName,";").
/* Recipient name */
PUT-LONG(RecipDescPtr,( 1 + ws-num-structs)) = 0. /* Reserved */
PUT-LONG(RecipDescPtr,( 5 + ws-num-structs)) = 1. /* RecipClass 1 = MAPI_TO */
PUT-LONG(RecipDescPtr,( 9 + ws-num-structs)) = GET-POINTER-VALUE(RecipNamePtr[ndx]).
/* Name */
PUT-LONG(RecipDescPtr,(13 + ws-num-structs)) = 0. /* Address */
PUT-LONG(RecipDescPtr,(17 + ws-num-structs)) = 0. /* EID Size */
PUT-LONG(RecipDescPtr,(21 + ws-num-structs)) = 0. /* Entry ID */
ASSIGN
num-structs = num-structs + {&STRUCT-SIZE}.
END.
/* ----- Build Message Details ----- */
SET-SIZE(MessageDescPtr) =
45 + (NUM-ENTRIES(RecipName,";") * 4).
PUT-LONG(MessageDescPtr,33) = NUM-ENTRIES(RecipName,";").
/* RecipCount */
Call with multiple recips -
RUN mapi(INPUT "you@work.com",
INPUT "john@domain.com;jane@domain.com",
INPUT "late for dinner",
INPUT "something came up..",
INPUT "c:\images\flowers.bmp").
DO ndx = 1 TO 10:
SET-SIZE(RecipNamePtr[ndx]) = 0.
END.
Hope this helps,
Sam
Sam,
I have tried the code you have written here, and it is complaining about subscripts only being used for arrays. I have written an example of the code below. Can you see what i am doing wrong?
RETURNS LOGICAL
( input pcOriginator as char, /* from */
input pcRecipient as char, /* to */
input pcSubject as char,
input pcBody as char,
input pcAttachment as char ) :
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
define var lpMessage as memptr no-undo.
define var lpOriginator as memptr no-undo.
define var lpOrigDesc as memptr no-undo.
define var lpRecipient as memptr no-undo.
define var lpRecipDesc as memptr no-undo.
define var lpSubject as memptr no-undo.
define var lpBody as memptr no-undo.
define var lpFilePathName as memptr no-undo.
define var lpFileName as memptr no-undo.
define var lpFilePath as memptr no-undo.
define var lpFileDesc as memptr no-undo.
define var cFileName as char no-undo.
define var cFilePath as char no-undo.
define var iOffset as int no-undo.
/*------------------- Build Originator structure ----------------------------*/
assign
set-size(lpOriginator) = length(pcOriginator) + 1
put-string(lpOriginator,1) = pcOriginator
set-size(lpOrigDesc) = 25
put-long(lpOrigDesc,1) = 0 /* Reserved */
put-long(lpOrigDesc,5) = 0 /* Recip Class MAPI_ORIG */
put-long(lpOrigDesc,9) = get-pointer-value(lpOriginator) /* Names */
put-long(lpOrigDesc,13) = 0 /* Address */
put-long(lpOrigDesc,17) = 0 /* EID Size */
put-long(lpOrigDesc,21) = 0.
/*------------------- Build Recipient structure ----------------------------*/
/* -----Build Recipient details ----- */
SET-SIZE(lpRecipDesc) = (25 * NUM-ENTRIES(pcRecipient,";")).
DO ndx = 1 TO NUM-ENTRIES(pcRecipient,";"):
SET-SIZE(lpRecipient[ndx]) = LENGTH(ENTRY(ndx,pcRecipient,";")) + 1. /* maximum = 255 */
PUT-STRING(lpRecipient[ndx],1) = ENTRY(ndx,pcRecipient,";").
/* Recipient name */
PUT-LONG(lpRecipDesc,( 1 + ws-num-structs)) = 0. /* Reserved */
PUT-LONG(lpRecipDesc,( 5 + ws-num-structs)) = 1. /* RecipClass 1 = MAPI_TO */
PUT-LONG(lpRecipDesc,( 9 + ws-num-structs)) = GET-POINTER-VALUE(lpRecipient[ndx]).
/* Name */
PUT-LONG(lpRecipDesc,(13 + ws-num-structs)) = 0. /* Address */
PUT-LONG(lpRecipDesc,(17 + ws-num-structs)) = 0. /* EID Size */
PUT-LONG(lpRecipDesc,(21 + ws-num-structs)) = 0. /* Entry ID */
ASSIGN num-structs = num-structs + {&STRUCT-SIZE}.
END.
/*---------------------- Build Subject structure ----------------------------*/
assign
set-size(lpSubject) = length(pcSubject) + 1
put-string(lpSubject,1) = pcSubject.
/*------------------- Build Message Body structure --------------------------*/
assign
set-size(lpBody) = 16000
put-string(lpBody,1) = pcBody + (if pcAttachment = '':U then
'':U
else chr(10) + chr(10) + ' ':U).
/*------------------- Build Attachments structure ---------------------------*/
if pcAttachment <> "" then
do:
assign
cFileName = entry(num-entries(pcAttachment, '\':U),pcAttachment, '\':U)
cFilePath = replace(pcAttachment,cFilename,'':U)
/*----------------- Set the full path spec -----------------*/
set-size(lpFilePathName) = length(pcAttachment) + 1
put-string(lpFilePathName,1) = pcAttachment
/*----------------- Set the only file spec -----------------*/
set-size(lpFileName) = length(cFileName) + 1
put-string(lpFileName, 1) = cFileName
/*----------------- Set up attachment structure -----------------*/
set-size(lpFileDesc) = 25
put-long(lpFileDesc,1) = 0 /* reserved */
put-long(lpFileDesc,5) = 0 /* flags */
put-long(lpFileDesc,9) = length(pcBody) + 2 /* position */
put-long(lpFileDesc,13) = get-pointer-value(lpFilePathName)
put-long(lpFileDesc,17) = get-pointer-value(lpFileName)
put-long(lpFileDesc,21) = 0
.
end.
/*---------------------- Build Message structure ----------------------------*/
assign
SET-SIZE(lpMessage) = 45 + (NUM-ENTRIES(pcRecipient,";") * 4).
put-long(lpMessage,1) = 0 /* Reserved */
put-long(lpMessage,5) = get-pointer-value(lpSubject) /* subject */
put-long(lpMessage,9) = get-pointer-value(lpBody) /* body */
put-long(lpMessage,13) = 0 /* Message type */
put-long(lpMessage,17) = 0 /* Date Received */
put-long(lpMessage,21) = 0 /* ConversationId */
put-long(lpMessage,25) = 1 /* Flags */
put-long(lpMessage,29) = get-pointer-value(lpOrigDesc) /* Originator */
PUT-LONG(lpMessage,33) = NUM-ENTRIES(pcRecipient,";").
put-long(lpMessage,37) = get-pointer-value(lpRecipDesc) /* Recipient */
put-long(lpMessage,41) = (if pcAttachment = '':U then
0
else 1) /* Number of attachments */
put-long(lpMessage,45) = (if pcAttachment = '':U then
0
else get-pointer-value(lpFileDesc)).
/*---------------------------- Send Message now -----------------------------*/
run MAPISendMail(input 0, /* current session */
input 0, /* UIParam */
input lpMessage, /* pointer to message structure */
input 0, /* 11, /* flags, 1 = MAPI_LOGON_UI + 2 = MAPI_NEW_SESSION + 8 = MAPI_DIALOG */ */
input 0, /* reserved */
output iRetCode).
GetMapiError(iRetCode).
/*---------------------------- Deallocate memory ----------------------------*/
assign
set-size(lpMessage) = 0
set-size(lpOriginator) = 0
set-size(lpOrigDesc) = 0
set-size(lpRecipient) = 0
set-size(lpRecipDesc) = 0
set-size(lpSubject) = 0
set-size(lpBody) = 0
set-size(lpFilePathName) = 0
set-size(lpFileName) = 0
set-size(lpFileDesc) = 0
set-size(lpFilePath) = 0
.
RETURN FALSE. /* Function return value. */
I cannot see how the code can take into account the different class types for the recipients. Please help!! (N.B this code is work in progress)
Kind Regards,
Emma "This stuff is driving me :crazy: " McDonald.