Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Using Indy to send mail via an Exchange Server in c++


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 8 - Last Post: Oct 12, 2017 10:12 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
charles leggette

Posts: 43
Registered: 7/17/00
Using Indy to send mail via an Exchange Server in c++  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 13, 2017 5:57 AM
I'm using Tokyo 10.2, Release 1. C++.

Here is the code I formerly used to send email via my non-exchang-server Earthlink.net account...I tried to update it for exchange server but it doesn't work...I know Remy has posted some examples for use of Exchange server, but I cannot find them....it may have been in Delphi, which I don't use and can't always track...

Does anyone have any suggested code for a send email process using X-Svr.

smtp1 = new TIdSMTP(NULL);
smtp1->Username = "charles dot leggette at dallasactuaries dot com"; // "charlie");
smtp1->Password = "m00ORuh6!";
smtp1->AuthType = TIdNNTPAuthType::atUserPass;

//
smtp1->Host = "a4d5d24e-11d9-4747-9f78-8120fa85220c at dallasactuaries dot com"; // "192.168.1.3";
msg = new TIdMessage(NULL);
msg->Body->Add(message2Send);
msg->From->Address = "charles dot leggette at dallasactuaries dot com";
msg->Recipients->EMailAddresses = sendTo;
msg->Subject = subjectline;
if (fileExists(attachedFile))
{
attachment = new TIdAttachmentFile(msg->MessageParts, attachedFile);
}
// set attachment's properties as needed...

// TIdMessagePart *tip =msg->MessageParts->Add();
xxxwrong smtp1->Connect("smtpauth.earthlink.net", 587);
smtp1->Send(msg);
if (fileExists(attachedFile))
{
delete attachment;
}
//
smtp1->Disconnect();
delete smtp1;
delete msg;
Goran Ekstrom

Posts: 136
Registered: 1/10/04
Re: Using Indy to send mail via an Exchange Server in c++  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 13, 2017 8:31 AM   in response to: charles leggette in response to: charles leggette
By no means an expert of this but I think Exchange Server uses IMAP:

https://en.wikipedia.org/wiki/Internet_Message_Access_Protocol
Remy Lebeau (Te...


Posts: 8,940
Registered: 12/23/01
Re: Using Indy to send mail via an Exchange Server in c++  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 13, 2017 8:46 AM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Goran Ekstrom wrote:

By no means an expert about this but I think Exchange Server uses
IMAP

No, it uses MAPI (Messaging Application Program Interface), not IMAP.

--
Remy Lebeau (TeamB)
Valence Crearer

Posts: 64
Registered: 11/27/99
Re: Using Indy to send mail via an Exchange Server in c++  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2017 9:35 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...

No, it uses MAPI (Messaging Application Program Interface), not IMAP.

--
Remy Lebeau (TeamB)

Interesting, but it must be able to use IMAP for reading e-mail, since i'm using IMAP4 to read office365...

By the way, does TIdIMAP4 use RPC or RPC over HTTP? I ask because M$ is going to obsolete regular RPC, and I want to know if TIdIMAP4 will stop working with office365 when that happens?

Remy Lebeau (Te...


Posts: 8,940
Registered: 12/23/01
Re: Using Indy to send mail via an Exchange Server in c++  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 12, 2017 10:12 AM   in response to: Valence Crearer in response to: Valence Crearer
Valence Crearer wrote:

By the way, does TIdIMAP4 use RPC or RPC over HTTP?

Neither. It is straight IMAP over TCP/SSL only. No RPC at all. Indy
has never had support for Exchange servers.

I ask because M$ is going to obsolete regular RPC, and I want to know
if TIdIMAP4 will stop working with office365 when that happens?

RPC, and RPC over HTTP, has nothing to do with IMAP. Microsoft's
change will not affect TIdIMAP4 at all.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 8,940
Registered: 12/23/01
Re: Using Indy to send mail via an Exchange Server in c++  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 13, 2017 8:44 AM   in response to: charles leggette in response to: charles leggette
charles leggette wrote:

I know Remy has posted some examples for use of Exchange server, but I
cannot find them...

No, I haven't, because Indy does not support Exchange. Exchange uses
its own proprietary protocol base on MAPI, not standard SMTP.

smtp1->Username = ...;
smtp1->Password = ...;

I sure hope those were not your real credentials being posted on a
public forum!

smtp1->AuthType = TIdNNTPAuthType::atUserPass;

The TIdNNTPAuthType enum is used with TIdNNTPServer, not TIdSMTP. Why
would you assign an NNTP auth type to an SMTP component?

The TIdSMTP::AuthType property uses the TIdSMTPAuthenticationType enum
instead:

smtp1->AuthType = TIdSMTPAuthenticationType::satDefault;


smtp1->Host =
"a4d5d24e-11d9-4747-9f78-8120fa85220c at dallasactuaries dot com";

An email address is not a valid host name to connect to. The only
reason this assignment even works at all is because you are overriding
it when passing a different hostname to Connect().

smtp1->Connect("smtpauth.earthlink.net", 587);

On port 587, you should be setting the TIdSMTP::UseTLS property to
utUseExplicitTLS, and assigning an SSLIOHandler (such as
TIdSSLIOHandlerSocketOpenSSL) to the TIdSMTP::IOHandler property.

if (fileExists(attachedFile))
{
delete attachment;
}

You don't need to do that. The attachment is owned by TIdMessage and
will be freed when TIdMessage is cleared/freed.

--
Remy Lebeau (TeamB)
Jarek Karciarz

Posts: 7
Registered: 2/28/17
Re: Using Indy to send mail via an Exchange Server in c++  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 14, 2017 1:39 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:

charles leggette wrote:

I know Remy has posted some examples for use of Exchange server,
but I cannot find them...

No, I haven't, because Indy does not support Exchange. Exchange uses
its own proprietary protocol base on MAPI, not standard SMTP.

smtp1->Username = ...;
smtp1->Password = ...;

I sure hope those were not your real credentials being posted on a
public forum!

smtp1->AuthType = TIdNNTPAuthType::atUserPass;

The TIdNNTPAuthType enum is used with TIdNNTPServer, not TIdSMTP. Why
would you assign an NNTP auth type to an SMTP component?

The TIdSMTP::AuthType property uses the TIdSMTPAuthenticationType enum
instead:

smtp1->AuthType = TIdSMTPAuthenticationType::satDefault;


smtp1->Host =
"a4d5d24e-11d9-4747-9f78-8120fa85220c at dallasactuaries dot com";

An email address is not a valid host name to connect to. The only
reason this assignment even works at all is because you are overriding
it when passing a different hostname to Connect().

smtp1->Connect("smtpauth.earthlink.net", 587);

On port 587, you should be setting the TIdSMTP::UseTLS property to
utUseExplicitTLS, and assigning an SSLIOHandler (such as
TIdSSLIOHandlerSocketOpenSSL) to the TIdSMTP::IOHandler property.

if (fileExists(attachedFile))
{
delete attachment;
}

You don't need to do that. The attachment is owned by TIdMessage and
will be freed when TIdMessage is cleared/freed.

I think exchange does support SMTP and POP3. It is a matter of an
mailbox configuration.
Remy Lebeau (Te...


Posts: 8,940
Registered: 12/23/01
Re: Using Indy to send mail via an Exchange Server in c++  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 14, 2017 2:13 PM   in response to: Jarek Karciarz in response to: Jarek Karciarz
Jarek Karciarz wrote:

I think exchange does support SMTP and POP3.

I didn't say it doesn't. But it ALSO uses (and prefers) it own
MAPI-based protocol, too. This is based on admin configuration.
TIdSMTP is not specific to Exchange, so it should work with Exchange
IF Exchange is configured to enable SMTP.

--
Remy Lebeau (TeamB)
charles leggette

Posts: 43
Registered: 7/17/00
Re: Using Indy to send mail via an Exchange Server in c++  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 24, 2017 5:14 AM   in response to: charles leggette in response to: charles leggette
charles leggette wrote:
I'm using Tokyo 10.2, Release 1. C++.

Here is the code I formerly used to send email via my non-exchang-server Earthlink.net account...I tried to update it for exchange server but it doesn't work...I know Remy has posted some examples for use of Exchange server, but I cannot find them....it may have been in Delphi, which I don't use and can't always track...

Does anyone have any suggested code for a send email process using X-Svr.

smtp1 = new TIdSMTP(NULL);
smtp1->Username = "charles dot leggette at dallasactuaries dot com"; // "charlie");
smtp1->Password = "m00ORuh6!";
smtp1->AuthType = TIdNNTPAuthType::atUserPass;

//
smtp1->Host = "a4d5d24e-11d9-4747-9f78-8120fa85220c at dallasactuaries dot com"; // "192.168.1.3";
msg = new TIdMessage(NULL);
msg->Body->Add(message2Send);
msg->From->Address = "charles dot leggette at dallasactuaries dot com";
msg->Recipients->EMailAddresses = sendTo;
msg->Subject = subjectline;
if (fileExists(attachedFile))
{
attachment = new TIdAttachmentFile(msg->MessageParts, attachedFile);
}
// set attachment's properties as needed...

// TIdMessagePart *tip =msg->MessageParts->Add();
xxxwrong smtp1->Connect("smtpauth.earthlink.net", 587);
smtp1->Send(msg);
if (fileExists(attachedFile))
{
delete attachment;
}
//
smtp1->Disconnect();
delete smtp1;
delete msg;

RackSpace Support gave me very good documentation on how to solve...all is good.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02