-2

I need information on how to allow an end user to compose an email, in Delphi code. Our Delphi version is Delphi Seattle (I think that is 10.1?) We use office365 as our email program. I need to pre-fill the recipient and some html in the body of the email. The end-user needs to complete the body of the email then click the send button.

We used to use the reliable "mailto" commandline that then displayed an email form. But it only works with plain text, no html. I now need to have html in the body of the email. I switched to using the ancient semi-reliable TOutlookApplication component and using it in code to do this thru OLE. I do see a dialog pop up, and the html appears to render correctly, but the send button seems to do nothing. Looking at the code used by TOutlookApplication, it appears that it's not been updated since the glory days of XP.

I am using Delphi Seattle. I don't think I can use Indy components with stmp because the email dialog has to be present to allow for the composing of the email, and I didn't see a way for Indy to display the form. Can anybody please tell me what I gotta do to make this work? If anybody wants to see my current code using TOutlookApplication, I can post it, but it's like 1,000 other Delphi examples of the component. Surely, others have overcome this, right?

I have additional information on this. I was running my application on a virtual machine, but my outlook was running in the desktop. Once I run the application on the desktop, it ran fine. I even received the test emails I hadn't from the vm. I believed the vm was aware of the desktop applications. My bad!

Debbie
  • 125
  • 1
  • 1
  • 6
  • Have you tried MAPI? – Jerry Dodge May 29 '18 at 22:36
  • 1
    "*I don't think I can use Indy components with stmp because the email dialog has to be present to allow for the composing of the email, and I didn't see a way for Indy to display the form*" - Indy is a library of **non-visual** components. If you need a UI, you have to provide your own (Outlook provides its own UI when accessed via OLE or MAPI). Indy has components for sending emails over SMTP (`TIdMessage` and `TIdSMTP`), you would simply display your own UI to get the user input, and then assign that input to the `TIdMessage` component and send it with the `TIdSMTP` component. – Remy Lebeau May 29 '18 at 23:26
  • Looks like a dupe of: https://stackoverflow.com/questions/8463866/creating-a-mail-with-attachment-in-outlook-and-displaying-it – Dave Nottage May 30 '18 at 00:35
  • The link from Dave Nottage is the example I used. It does NOT work with Office365. I was pretty specific that it maybe used to work in days of yore, but no longer. – Debbie May 30 '18 at 19:29
  • Jerry Dodge, What is MAPI and how might that make a difference? – Debbie May 30 '18 at 19:33
  • Office365 is not an email program, it is a service. You must use an application or write some code to send email. – Sertac Akyuz May 31 '18 at 17:04

1 Answers1

0

The problems I experienced were due to running on a virtual machine. If there are other dolts trying to run an app that uses OLE to access Outlook from a VM, make sure you have a Outlook ON THE VM. Or run your app from the someplace that has Outlook installed, like a desktop.

Debbie
  • 125
  • 1
  • 1
  • 6