Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Change the "From" mail address in outlook OLE (https://www.delphipraxis.net/43254-change-mail-address-outlook-ole.html)

Delphi-Lover 31. Mär 2005 14:39


Change the "From" mail address in outlook OLE
 
Hello,

With a Delphi program I create an automatic E-Mail message, but the user using the program might have two inboxes in outlook. Like, one of the user self and another that is shared with others. Now when I create an E-Mail the MailItem always takes the Mail-Address of the user. Is there a way to tell the MailItem to use the other sendersaddress. It create the Outlook object in the normal fasion:

Code:
OutlookApplication := CreateOleObject('Outlook.Application');
MailItemSend := OutlookApplication.CreateItem(olMailItem);
MailItemSend.Recipients.Add(email@SomeUser.com');

I like to do this !!!
//MailItemSend.FromAddress:='email@aMailAddress.com';
 
MailItemSend.Subject:=My Subject';
MailItemSend.Body:='Hello Delphi PRAXiS Forum';
MailItemSend.Display;
Thanks,

Rob.

Delphi-Lover 31. Mär 2005 15:52

Re: Change the "From" mail address in outlook OLE
 
Hello,

I found the answer myself. There is a mailitem property called:

SentOnBehalfOfName

so : MailItemSend.SentOnBehalfOfName:='Name@specialAddr ess.com';

When you display the mailitem you will see an extra line at the top of the mail with the FROM address and a FROM button, like the normal To: and CC: lines. This does NOT mean you can just send an email with another sender address. The address you put in the "SentOnBehalfOfName" property will be verified if you send the message. If you don't have this address attached to your exchange server login. (the current user) then outlook will raise a message that you can not send the email with this address.

Greets and much luck to this PRAXis Website!!

Delphi Lover.

alcaeus 31. Mär 2005 15:55

Re: Change the "From" mail address in outlook OLE
 
Zitat:

Zitat von Delphi-Lover
This does NOT mean you can just send an email with another sender address. The address you put in the "SentOnBehalfOfName" property will be verified if you send the message. If you don't have this address attached to your exchange server login. (the current user) then outlook will raise a message that you can not send the email with this address.

Just to make it a bit more precise: You can send an email with any senders address, unless the SMTP server is configured to require a login. By default, SMTP servers don't require that. However, more and more email services require a login before allowing you to send emails. GMX for example requires a logon and cross-checks the submitted from address with the address specified in the account. Therefore, this just depends on the mail server, and not Outlook itself.

Greetz
alcaeus


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:22 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz