1. Jon Stoller
  2. PowerBuilder
  3. Tuesday, 26 June 2018 19:07 PM UTC

How can I pop up a "New Email" window in Microsoft Outlook from PowerBuilder. 

I am able to "Send" an email from PowerBuilder via Microsoft Outlook.  I can tell it the email address to send it to, enter the Subject, Text for the body, enter a CC, and attach a file.
PowerBuilder does send the email.  

However, instead of sending it, I need to pop up the New Email instead of sending it. 

NOTE:  Assume Outlook will be running and open for the user


How can I do this so the user sees the email before it is sent, ande let the user click on "Send" to send it.. 
The above items - subject, cc's, attachment, etc., should be in the new email when it pops up. 
I tried using the code that sends the email - see below - except I changed the "ole.item.Send" statement. 
However, I couldn't get it to create the email and put me in the Outlook window. 

Here is a screen sample of what I want the code to do. I would like it to pop up an outlook window like this:

The text below is a snapshot of the code I used it to send the email. 
To put the user into Outlook, is it a matter of just changing the "ole_item.send" instruction, or do I need to do something else?  
(NOTE - I took out most of the code to handle errors and bad return codes):

 String    ls_folderfile, ls_email_addr, ls_subject, ls_email_text_message, ls_sender_addr
 integer    li_return, li_result
 OLEObject ole_item, ole_attach, ole_outlook

 ole_outlook = Create OLEObject
 li_result = ole_outlook.ConnectToNewObject("outlook.application")
 if li_result <> 0 then
     Messagebox("Outlook Error","......")
     destroy ole_outlook
          li_return = -1
 else
            ole_item = ole_outlook.CreateItem(0)
            ole_item.SentOnBehalfOfName = ls_sender_addr
            ole_item.To = ls_email_addr
            ole_item.Cc = 'cc@madeup.domain.com'
            ole_item.Subject = ls_subject
            ole_item.Body = ls_email_text_message + char(13)
            ole_attach = ole_item.Attachments
            ole_attach.Add(ls_folderfile)

            ole_item.Send                 //Sends Email - How can I pop up the new email instead of Sending it ?
end if

 ole_outlook.DisconnectObject()
 destroy ole_outlook

Thank you ahead of time for any help.
Jon Stoller
AKA Software

John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 27 June 2018 20:14 PM UTC
  2. PowerBuilder
  3. # 1

Here are links to a couple of MSDN topics I find invaluable when trying to coerce Outlook into doing what I need it to do from PowerBuilder:

Outlook Object Model Reference:
https://msdn.microsoft.com/en-us/library/bb208225.aspx

Object model (Outlook VBA Reference):
https://msdn.microsoft.com/en-us/VBA/Outlook-VBA/articles/object-model-outlook-vba-reference

Comment
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Tuesday, 26 June 2018 20:20 PM UTC
  2. PowerBuilder
  3. # 2

//ole_item.Send             //Sends Email - 

ole_item.Display  //pop up the new email instead of Sending it 

Comment
  1. Jon Stoller
  2. Wednesday, 27 June 2018 01:15 AM UTC
It works!



Thank you for the help.

  1. Helpful
  1. Jon Stoller
  2. Wednesday, 27 June 2018 01:23 AM UTC
Is there a list of other key words like this for Outlook? 



For other products ?

  1. Helpful
  1. Roland Smith
  2. Wednesday, 27 June 2018 11:15 AM UTC
Here is the Outlook docs. It is for 2007 but should be compatible with newer ones.



https://msdn.microsoft.com/en-us/library/bb208225.aspx

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.