1. Miller Rhodes
  2. PowerBuilder
  3. Friday, 22 September 2023 22:24 PM UTC

Currently we use an OLE object to send mail and it works fine.  We have a 32 bit build of our application and a 32 bit version of Outlook.

Most of our organization uses 64 bit Outlook so those people cannot use the email function.  In an attempt to remedy this, I upgraded my

Outlook to 64 bit and created a 64 bit build of our application.  I am currently using Powerbuilder 2022 R1.  When I tried the function ,

I received this error :


 

I went and executed the code from the IDE in 64 bit mode and discovered that this code ran fine :

li_ret_ole = iole_outlook.ConnectToNewObject("Outlook.Application")
if li_ret_ole <> 0 THEN
   MessageBox("Contact Programmer", "OLE ConnectToNewObject Error - Returns: " + string(li_ret_ole), StopSign!)
   DESTROY iole_outlook
    return -1
END IF

 

Everything seemed to be going fine until I hit the code in BOLD below:

OLEObject lole_mailitem, lole_attachment, lole_recipients

string ls_rtn_message

lole_mailitem = CREATE OLEObject
lole_attachment = CREATE OLEObject
lole_recipients = CREATE OLEObject

//Variables for CP_REPORT_DISTRIBUTION update
long ll_cp_report_distribution_email_no, ll_email_status_no
string ls_email_address, ls_FileName, ls_pathname
long i
integer li_attachment_count
string ls_subject, ls_message, ls_date

string ls_owner


ls_date = string(date(idt_current_414_generation), 'mmmm yyyy')

ls_subject = ' Appendices for ' + ls_date
ls_message = 'Attached are the Appendix Report(s) for ' + ls_date

//dsh 03/31/2011 - Multiple emails to recipients
if al_total_parts > 1 then
ls_subject = ls_subject + ': ' + 'Part ' + string(al_part_x_of) + ' of ' + string(al_total_parts)
ls_message = ls_message + ': ' + 'Part ' + string(al_part_x_of) + ' of ' + string(al_total_parts)
end if

try
lole_mailitem = iole_outlook.CreateItem(0)
lole_attachment = lole_mailitem.Attachments

for i=al_start_row to al_end_row

ls_FileName = ads_unsent.getitemstring(i, 'file_name')
ls_pathname = ads_unsent.getitemstring(i, 'path_name')
ls_email_address = ads_unsent.getitemstring(i, 'email_address')
ls_owner = ads_unsent.getitemstring(i, 'owner')

lole_attachment.Add(ls_pathname, 1, 1, "")

next

 

 

Is there a pivot we need to make in order to get this to work ?

 

 

Accepted Answer
Mark Goldsmith Accepted Answer Pending Moderation
  1. Sunday, 24 September 2023 14:20 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Miller,

Just expanding on Miguel's point, I would add that simply by virtue of your app being 32 bit and Outlook being 64 bit does not automatically mean you have a bitness issue (see more here: https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/building-mapi-applications-on-32-bit-and-64-bit-platforms). If you're not using the MAPI address book functionality, accessing Outlook folders etc. and all you're doing is sending the e-mail, then you can use a 32 bit app with 64 bit Outlook (and I have this working in a customer's app). From the code you've provided it looks like all you're trying to do is send the e-mail. Maybe that's not actually the case or maybe you have a different issue as to why that wasn't working.

As to the specific error you have now, I too wondered if the file in ls_pathname actually exists and whether it's correct to assume that ls_pathname actually contains both the path name and the file name but if the same code (and file being added) works in 32 bit that likely isn't the problem. How large is the attachment you're trying to add? Any chance you're using Windows API calls (that can't be seen from the code you provided) that now have to be modified to work with a 64 bit app? Any chance you're missing some 64 bit PB runtime files? I couldn't tell from your original post whether it did work from the IDE or was maybe just a deployment issue.

Regards,

Mark

Comment
There are no comments made yet.
Miller Rhodes Accepted Answer Pending Moderation
  1. Thursday, 28 September 2023 14:39 PM UTC
  2. PowerBuilder
  3. # 1

Has the bitness thing always been this way where you could go 32 to 64 and 64 to 32 for the OLE emailing or did it change with a particular version ?

Comment
  1. mike S
  2. Thursday, 28 September 2023 17:20 PM UTC
always that way. I bet bruce knows for sure, but my understanding is that ole is not bit specific (or if it is then windows translates).

excel and others work the same exact way
  1. Helpful 1
There are no comments made yet.
Miller Rhodes Accepted Answer Pending Moderation
  1. Sunday, 24 September 2023 22:07 PM UTC
  2. PowerBuilder
  3. # 2

Thanks Mike. I added your provided code to help out with things:

 

//loop to add in all attachments:
if fileexists( as_attachmentlist[ll_x] ) then lole_attach.add(as_attachmentlist[ll_x])

Comment
There are no comments made yet.
Miller Rhodes Accepted Answer Pending Moderation
  1. Sunday, 24 September 2023 22:05 PM UTC
  2. PowerBuilder
  3. # 3

ls_pathname contains the full path and file name.

Unfortunately, I was relying on someone else's opinion on the bitness issue.  The problem here was that the file was not actually there. We create them on the fly and there was an issue there.  

I was able to successfully send an email from 32 bit Powerbuilder using 64 bit Outlook and also send from my 64 bit build as well.

We are only sending email. I think this problem is resolved for now

 

Comment
  1. Mark Goldsmith
  2. Monday, 25 September 2023 14:16 PM UTC
Glad to hear you got it resolved Miller and thanks for the update on what was your actual issue.
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Sunday, 24 September 2023 14:42 PM UTC
  2. PowerBuilder
  3. # 4

My app is still 32 bit and works with 64 bit outlook for years.  

 

the major difference i see is that I attach without all the arguments that you use.  I have no idea what they might be

lole_attach = iole_item.Attachments

//loop to add in all attachments:
if fileexists( as_attachmentlist[ll_x] ) then lole_attach.add(as_attachmentlist[ll_x])

 

 

Comment
  1. Mark Goldsmith
  2. Sunday, 24 September 2023 15:13 PM UTC
Parameter 2 = type of attachment, parameter 3 = position to place the attachment and Parameter 4 = attachment display name.

Agreed Mike, the above parameters are all optional anyway and the latter 2 only apply to an e-mail that is in Rich Text format and are still just optional.
  1. Helpful 2
There are no comments made yet.
Miller Rhodes Accepted Answer Pending Moderation
  1. Saturday, 23 September 2023 20:34 PM UTC
  2. PowerBuilder
  3. # 5

Well it's not working. That's why I'm asking the question

Comment
  1. Miguel Leeuwe
  2. Sunday, 24 September 2023 09:23 AM UTC
Have you tried with a 32 bit PB executable?

What's in you variables? I'm willing to try and reproduce this, but need more information.

regards.
  1. Helpful 1
  1. Miguel Leeuwe
  2. Sunday, 24 September 2023 09:24 AM UTC
Added to that, "ls_pathname" seems to implicate a path name, not a path + FILENAME to whatever your want to attach?
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Saturday, 23 September 2023 20:30 PM UTC
  2. PowerBuilder
  3. # 6

"Most of our organization uses 64 bit Outlook so those people cannot use the email function"

That's not true. it should work also when having a 32 bit PB app using 64 bit Office.

 

Comment
  1. Miller Rhodes
  2. Sunday, 24 September 2023 22:09 PM UTC
Thanks to everyone who responded in this thread. I think this discussion will be useful as there is some misinformation out there that would lead one to assume that the bitness is the problem ( like me ). I stand corrected.
  1. Helpful 1
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.