Hi

Has anyone used SendMapiMail with Thunderbird? I used SendMapiMail with 
Outlook very successfully but when I changed the default email to 
Thunderbird (without changing my program!) it complained that there was 
no recipient. Debug and experience of Outlook says that there is. 
SendResult is 15: MAPI_E_BAD_RECIPTYPE

Ideally, I would like this to work with both Outlook and Thunderbird as 
I also have an application in the field which uses SendMapiMail and, of 
course, I have no idea which email the target PC uses.

The problem was seen in Thunderbird 1.0.7 and I upgraded to 1.5 Beta 2 
without effect. Delphi 7, Windows 2000.


Bobby Clarke




function SendEmail(const Subject, MesText: string; 
ToList,CcList,AttList: TStringList;var MemoLog: TMemo): Boolean;
var
  Recips: packed array[0..(MaxRecips - 1)] of TMapiRecipDesc;
  Files: packed array[0..(MaxFiles -1)] of TMapiFileDesc;
  Mes: TMapiMessage;
  //Session: LHANDLE;
  SendResult, i, j, TotRecips: Integer;
begin
  i := ToList.Count;
  j := CcList.Count;
  TotRecips := i + j;

  if (ToList.Count = 0) or (TotRecips > MaxRecips) or (AttList.Count > 
MaxFiles) then
    begin
       Result := False;
       exit;
     end
  else
    begin
      // build the recipient data structures required for a mapi message
      for i := 0 to (TotRecips - 1) do
      begin
        Recips[i].ulReserved := 0;                  // Reserved for 
future use
        Recips[i].ulEIDSize := 0;                   // Count in bytes of 
size of pEntryID
        Recips[i].lpEntryID:= nil;                  // System-specific 
recipient reference
        Recips[i].lpszAddress := '';                // Recipient address 
(optional) doesn't appear to be used any more
        if i < ToList.Count then
          begin
            Recips[i].ulRecipClass := MAPI_TO;        // Recipient class 
MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG
            Recips[i].lpszName := PChar(ToList[i]);   // Recipient name 
(address book)
          end
        else
          begin
            j := i - ToList.Count;
            Recips[i].ulRecipClass := MAPI_CC;
            Recips[i].lpszName := PChar(CcList[j]);
          end;
    end;

    // setup any file attachments
    for i := 0 to AttList.Count -1 do
    begin
      Files[i].ulReserved := 0;                   // reserved by mapi 
for future use
      Files[i].flFlags := 0;                      // flags for Ole 
objects - not used
      Files[i].nPosition := $FFFFFFFF;            // position attachment 
rendered in message - $FFFFFFFF indicates not used
      Files[i].lpszPathName := PChar(AttList[i]); // full qualified 
source path of file
      Files[i].lpszFileName := '';                // optional file name 
as seen by recipient - not used here
      Files[i].lpFileType := nil;                 // optional pointer to 
file type descriptor
    end;

    // setup the mapi message
    Mes.ulReserved := 0;
    Mes.lpszSubject := PChar(Subject);      // Message Subject
    Mes.lpszNoteText := PChar(MesText);     // Message Text
    Mes.lpszMessageType := '';              // Message Class (not 
required for simple mapi)
    Mes.lpszDateReceived := '';             // Date Received in 
YYYY/MM/DD HH:MM format (used when reading mail)
    Mes.lpszConversationID := '';           // Conversation thread ID 
(used for newsgroup messages)
    Mes.flFlags := 0;                       // unread, return receipt 
(used when reading messages)
    Mes.lpOriginator := nil;                // Originator descriptor 
(used when reading messages)
    Mes.nRecipCount := TotRecips;           // Number of recipients
    Mes.lpRecips := Addr(Recips);           // Recipient descriptors
    Mes.nFileCount := AttList.Count;        // # of file attachments
    Mes.lpFiles := Addr(Files);             // Attachment descriptors

    SendResult := MapiSendMail(0,0,Mes,0,0);

    <rest of the code>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/i7folB/TM
--------------------------------------------------------------------~-> 

-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to