🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10614

Re: SEND TEXT EMAIL

#10614
From: Dave
Date: Wed, 31 Mar 2004 14:35
58 lines
2609 bytes
On Wed, 31 Mar 2004 08:17:43 -0800, Linda Yandell wrote:

> HELP,
> 
> I need to send "hello world" To an email address from C/C++ Interface under
> win32.  How can this be done under winsock or berkely sockets or whatever?
> 
> Thank you,
> 
> Linda

Linda,
you can do it with Indy or with FastNet delivered with Borland
among others.

The following example uses FastNet.

drop a TNMSMTP Component (FastNet) on a new Project Form and
a TButton. Place the Following code in the ButtonClick Event.

  NMSMTP1->Host = "your smtp mail server";
  NMSMTP1->Port = 25;
  NMSMTP1->UserID = "your user id";
  NMSMTP1->Connect();

  NMSMTP1->PostMessage->FromAddress = "your email";
  NMSMTP1->PostMessage->FromName = "your name";
  NMSMTP1->PostMessage->Subject = "...";
  NMSMTP1->PostMessage->ToAddress->Add("x@x.com");
//  NMSMTP1->PostMessage->ToBlindCarbonCopy->Add(Edit9->Text);
//  NMSMTP1->PostMessage->ToCarbonCopy->Add(Edit8->Text);
//  NMSMTP1->PostMessage->Attachments->Add("C:\\Program
//Files\\PostiT.rar");
  NMSMTP1->PostMessage->Body->Add("This file contains postit.rar");
  NMSMTP1->SendMail();
}
//-------------------------------------------------------------------------

Add the following in the NMSMTPSuccess Event

void __fastcall TForm1::NMSMTP1Success(TObject *Sender)
{
  NMSMTP1->Disconnect();
  ShowMessage("Post-it was sent !");
  Application->Terminate();
}
//-------------------------------------------------------------------------

Add the following in the NMSMTPFailure Event

void __fastcall TForm1::NMSMTP1Failure(TObject *Sender)
{
  ShowMessage("SendMail Failed.");
}
//-------------------------------------------------------------------------

HTH,
David
Technical Details
Message-ID: <1u2ml0twlr5r5$.1jv65mg8nkhyr$.dlg@40tude.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <406ad2b6$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,88a54bb69cd2282f
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-03-31 06:40:51 PST
From: Dave <dave_xse@-spam-hotmail.com>
Subject: Re: SEND TEXT EMAIL
Newsgroups: borland.public.cppbuilder.nativeapi
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
References: <406ad2b6$1@newsgroups.borland.com>
Date: Wed, 31 Mar 2004 22:35:28 +0800
Message-ID: <1u2ml0twlr5r5$.1jv65mg8nkhyr$.dlg@40tude.net>
User-Agent: 40tude_Dialog/2.0.5.1
NNTP-Posting-Host: 202.72.161.99
X-Trace: newsgroups.borland.com 1080743728 202.72.161.99 (31 Mar 2004 06:35:28 -0800)
Lines: 58
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail