mvcad
mvcad

Reputation: 1

Send email with RAD Studio cpp11

I am trying to port an old Borland C++ application to the new RAD studio 11 format an I cannot get it to send emails using Outlook_2K_SRVR.h. Would anyone have sample code to send emails with RAD studio 11? in C++?

This is the part of the code that does not work.


`
`#define  Outlook_2k_olMailItem         OlItemType::olMailItem`

`//---------------------------------------------------------------------------
#pragma package(smart_init)

//----------------------------------
// emailing ...
//----------------------------------
#pragma link "Outlook_2K_SRVR"  

void __fastcall TLicMainForm::Button1Click(TObject *Sender)
{
MailItem = (MailItemPtr)(Outlook->CreateItem(Outlook_2k_olMailItem));  
MailItem->set_To((MailAddressee.w_str() ));
  MailItem->set_Subject((MailSubject.w_str()));
  MailItem->set_Body((MailFullText.w_str()) );
  MailItem->Attachments->Add( (TVariant)(FDispatch_path), TNoParam(), TNoParam(), TNoParam() );

  MailItem->Send();
}`

` this is the one of the many errors

[ilink32 Error] Error: Unresolved external '__fastcall Outlook_2k::TSyncObject::Disconnect()' referenced from C:\mypath\OUTLOOK_2K_SRVR.OBJ
[ilink32 Error] Error: Unable to perform link

Thanks in advance

I tried to re-compile "Outlook_2k_SRVR.obj" with the .h file that comes in the vcl folder but no luck.

Upvotes: 0

Views: 93

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49455

It seems Outlook is disconnected right after the Send method is called. Most probably the new RAD studio release COM references quickly enough. You may try to get any Outlook window and keep it alive while Outlook is automated and the message is sent out. Try to use the Explorers.Add or Inspectors.Add methods to create an Outlook window, be aware that without calling the Display method the window will be kept not visible to the end user.

Upvotes: 0

Related Questions