🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #4278

Re: MAPI lpSender.lpszAddress

#4278
From: MrT
Date: Wed, 02 Mar 2005 00:30
160 lines
6303 bytes
Remy Lebeau (TeamB) wrote:
> 
> Please show your actual code.

At <----- below, the correct infomation is in &lpSender but when email 
dialog opens, something else.

//---------------------------------------------------------------------------
int __fastcall TeMailDM::SendMail(String Subject, String Body, String 
FileName, String SenderName, String SenderEMail,
String RecipientName, String RecipientEMail)
{
   String MailFileName = SuP.CommonPath + 
"\\uploads\\activememberemaillist.txt";
   TStringList *EMailList = new TStringList;
   TMapiRecipDesc *Recipients;
   int EMailCount;
   DynamicArray<AnsiString> NameArray;
   DynamicArray<AnsiString> AddressArray;

   if (RecipientEMail == "FullMembers" || RecipientEMail == "AllMembers")
      {
       EMailList->Clear();
       EMailList->LoadFromFile(MailFileName);
       EMailCount = EMailList->Count;
       NameArray.Length = EMailCount;
       AddressArray.Length = EMailCount;
       Recipients = new TMapiRecipDesc[EMailCount];
       for (int i = 0; i <= EMailList->Count -1; i++)
          {
           Recipients[i].ulReserved = 0;
           Recipients[i].ulRecipClass = MAPI_TO;
           String Base = EMailList->Strings[i];
           NameArray[i] = Base.SubString(Base.Pos(",")+1 , 
Base.Pos(",<") - (Base.Pos(",") + 1));
           AddressArray[i] = Base.SubString(Base.Pos("<"), Base.Pos(">") 
+ 1 - Base.Pos("<"));
           Recipients[i].lpszName = NameArray[i].c_str();
           Recipients[i].lpszAddress = AddressArray[i].c_str();
           Recipients[i].ulEIDSize = 0;
           Recipients[i].lpEntryID = 0;
          }
      }
    else
      {
       EMailCount = 1;
       Recipients = new TMapiRecipDesc[1];
       Recipients[0].ulReserved = 0;
       Recipients[0].ulRecipClass = MAPI_TO;
       Recipients[0].lpszName = RecipientName.c_str();
       Recipients[0].lpszAddress = RecipientEMail.c_str();
       Recipients[0].ulEIDSize = 0;
       Recipients[0].lpEntryID = 0;
      }
   TStringList *TestList;
   TestList = new TStringList();
   TestList->Clear();
   unsigned long flFlags;
   TMapiMessage MapiMessage = {0};
   TMapiRecipDesc lpSender = {0};
   TMapiFileDesc MapiFileAttach = {0};
   unsigned int hSession;
   ULONG MapiError = SUCCESS_SUCCESS;

   if (Subject != "")
     MapiMessage.lpszSubject = Subject.c_str();

   if (Body != "")
     MapiMessage.lpszNoteText = Body.c_str();

   if (SenderEMail != "")
     {
      lpSender.ulRecipClass = MAPI_ORIG;
      if (SenderName == "")
        lpSender.lpszName = SenderEMail.c_str();
      else
        lpSender.lpszName = SenderName.c_str();
      lpSender.lpszAddress = SenderEMail.c_str();
      lpSender.ulReserved = 0;
      lpSender.ulEIDSize = 0;
      lpSender.lpEntryID = NULL;
      MapiMessage.lpOriginator = &lpSender; <--------------------
     }

     if (RecipientEMail != "")
       {
        MapiMessage.nRecipCount = EMailCount;
        MapiMessage.lpRecips = Recipients;
       }
     else
       MapiMessage.lpRecips = NULL;

     if (FileName == "")
       {
        MapiMessage.nFileCount = 0;
        MapiMessage.lpFiles = NULL;
       }
     else
       {
        MapiFileAttach.nPosition = 0xFFFFFFFF;
        MapiFileAttach.lpszPathName = FileName.c_str();
        MapiMessage.nFileCount = 1;
        MapiMessage.lpFiles = &MapiFileAttach;
       }
//     TestList->Add("Pre MapiLogon Count: " + IntToStr(::GetTickCount()));
//     MapiError = MapiLogOn(0, NULL, NULL, 0, 0, &hSession);
//     TestList->Add("Post MapiLogon Count: " + IntToStr(::GetTickCount()));

      MapiError = SUCCESS_SUCCESS;
      if (MapiError == SUCCESS_SUCCESS)
        {
         flFlags = MAPI_DIALOG |MAPI_LOGON_UI | MAPI_NEW_SESSION;
         TestList->Add("Pre SendMail Count: " + IntToStr(::GetTickCount()));
        }
      HINSTANCE MapiModule;
      TFNMapiSendMail SM;
      MapiModule = LoadLibrary(MAPIDLL.c_str());
      if (MapiModule != NULL)
        {
         SM = (TFNMapiSendMail) GetProcAddress(MapiModule, "MAPISendMail");
         if (SM != NULL)
           {
            MapiError = SM(0, reinterpret_cast<unsigned 
int>(Application->Handle), MapiMessage, flFlags, 0);
            TestList->Add("Post SendMail Count: " + 
IntToStr(::GetTickCount()));
            if (MapiError == SUCCESS_SUCCESS)
              {
               TestList->Add("Pre MapiLogOff Count: " + 
IntToStr(::GetTickCount()));
//              MapiError = MapiLogOff(hSession,0, 0, 0);
               TestList->Add("Post MapiLogOff Count: " + 
IntToStr(::GetTickCount()));
               EMailAfterLogoff();
              }
            else
              {
               EMailMapiError(MapiError);
              }
           }
         else
           {
            ShowMessage("Unable to get MapiSendMail process entry point.");
           }
        }
      else
        {
         ShowMessage("Unable to load Mapi.dll.");
        }
   delete[] Recipients;

   delete EMailList;

   TestList->SaveToFile("MapiPerfomanceFile.txt");
   delete TestList;

   if (MapiError != SUCCESS_SUCCESS)
     EMailMapiError(MapiError);
   return MapiError;
}
Technical Details
Message-ID: <422508d3@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4224a2c8@newsgroups.borland.com> <4224b68c@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,86cf258eb36d0745
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 01 Mar 2005 19:30:15 -0500
From: MrT <contact@heat-mi.org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: Re: MAPI lpSender.lpszAddress
References: <4224a2c8@newsgroups.borland.com> <4224b68c@newsgroups.borland.com>
In-Reply-To: <4224b68c@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 64.108.158.88
Message-ID: <422508d3@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1109723347 64.108.158.88 (1 Mar 2005 16:29:07 -0800)
Lines: 161
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail