Recent

Author Topic: How to override sender's id while sending mail?  (Read 5985 times)

vks

  • New Member
  • *
  • Posts: 33
How to override sender's id while sending mail?
« on: March 18, 2015, 08:10:26 am »
hello,

I have written e-mailing code in deplhi through outlook.

Code: [Select]
procedure TForm6.EnrollClick(Sender: TObject);
  const
    olMailItem = 0;
    olByValue = 1;
  var
    OutlookApp, MailItem : OLEVariant;
  begin

    try
      OutlookApp := GetActiveOleObject('Outlook.Application');
    except
      OutlookApp := CreateOleObject('Outlook.Application');
    end;
    try
      wsRecep:=UTF8Decode(mail_id);
      MailItem := OutlookApp.CreateItem(olMailItem);
      MailItem.Recipients.Add(wsRecep);
      MailItem.Subject := 'Training Enrollemnt Details';
      MailItem.Body := ('You have enrolled to the training courses');
      MailItem.Send;
      ShowMessage('Mail sent Successfully');
    finally
      OutlookApp    := VarNull;
    end;
end;   

How do I add a Cc field and override sender's address?
« Last Edit: March 18, 2015, 08:14:14 am by vks »

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: How to override sender's id while sending mail?
« Reply #1 on: March 18, 2015, 03:26:12 pm »
https://msdn.microsoft.com/EN-US/library/office/ff861252.aspx

Sender account (mailitem properties):

- SendUsingAccount: see this sample, for instance (you may have to use " ....items[ i ] " instead),

http://stackoverflow.com/questions/8620016/sending-an-email-from-a-specific-account-using-outlook-and-delphi)

and this one:

https://msdn.microsoft.com/en-us/library/office/ff865634%28v=office.15%29.aspx

- or SentOnBehalfOfName (shared mailbox): a sample here,

http://www.slipstick.com/developer/code-samples/send-email-address-vba/


Copies (mailitem properties):

- BCC
- and CC
« Last Edit: March 18, 2015, 03:37:11 pm by ChrisF »

vks

  • New Member
  • *
  • Posts: 33
Re: How to override sender's id while sending mail?
« Reply #2 on: March 19, 2015, 12:26:32 pm »
Thank you so much  :) :)

 

TinyPortal © 2005-2018