Watch, Follow, &
Connect with Us

Welcome, Guest
Guest Settings
Help

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


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


Permlink Replies: 5 - Last Post: Sep 14, 2017 2:13 PM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
charles leggette

Posts: 27
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: 130
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,637
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)
Remy Lebeau (Te...


Posts: 8,637
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,637
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)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02