We help IT Professionals succeed at work.
Get Started

send email with outlook (from delphi-application). Send-Window does not open.

formi
formi asked
on
196 Views
Last Modified: 2020-02-14
Hi

using Delphi 10.1 and outlook 365.
There are only some clients where I have the problem: I can not send EMail from my application. On my computer and most other clients-computers it works. But there are computers, where only outlook is startet but no send-window is opend. Retring a second time, outlook is startet also a second time...
  OutlookApplication1.Connect;
  try
    MailItem1 := OutlookApplication1.CreateItem(olMailItem)  as _MailItem;
    while toAdress <> '' do
    begin
      if Pos(';',toAdress) > 0 then
      begin
        MailItem1.Recipients.Add(Copy(toAdress,1,Pos(';',toAdress)-1));
        Delete(toAdress,1,Pos(';',toAdress));
      end
      else
      begin
        MailItem1.Recipients.Add(toAdress);
        toAdress := '';
      end;
    end;
    MailItem1.CC := ToCC;
    MailItem1.BCC := ToBCC;
    MailItem1.Subject := Subject;
    if EMailOutlookAbsender = '' then  //local definitions?
    begin
      if Pos('@',getOptionMandantS('EMail_Absender','')) > 0 then
        MailItem1.SendUsingAccount := OutlookApplication1.Session.Accounts.Item(getOptionMandantS('EMail_Absender',''));
    end
    else MailItem1.SendUsingAccount := OutlookApplication1.Session.Accounts.Item(EMailOutlookAbsender); //globale Einstellung
    Mailitem1.BodyFormat := olFormatHTML;
    //the default signature is added
    ObjectInspector := Mailitem1.getinspector;

    if ObjectInspector.EditorType = olEditorWord then
    begin
      WordEditor := ObjectInspector.WordEditor;
      WordEditor.Characters.item(1).InsertBefore(Htmltext);
    end
    else
    begin
      Mailitem1.HtmlBody := StringReplace(Mailitem1.HtmlBody,'<body>','<body>'+Htmltext,[rfReplaceAll,rfIgnoreCase]);
    end;
    if AttachedFileNames <> nil then
    begin
      for i := 0 to AttachedFileNames.Count - 1 do
        MailItem1.Attachments.Add(AttachedFileNames[i], EmptyParam, EmptyParam, EmptyParam);
    end;
    MailItem1.Display(true);

Open in new window

Any idea where the problem is?
Thanks, Peter
Comment
Watch Question
software developer
CERTIFIED EXPERT
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE