1. ATK Gimmy Susan
  2. PowerBuilder
  3. Friday, 28 December 2018 16:18 PM UTC

Hi Guru

i try to send mail from Powerbuilder.

Where is the problem in my simple code ?

mailSession mSes
mailReturnCode mRet
mailMessage mMsg

mSes = create mailSession // Create a mail session


mRet = mSes.mailLogon(mailNewSession!)  // Log on to the session
IF mRet <> mailReturnSuccess! THEN
   MessageBox("Mail", 'Logon failed.')
   RETURN
END IF

// Populate the mailMessage structure
mMsg.Subject = "HI"
mMsg.NoteText = 'from Italy'
mMsg.Recipient[1].name = 'xxxxxx.yyyyyyy@gmail.com'

mRet = mSes.mailSend(mMsg) // Send the mail

IF mRet <> mailReturnSuccess! THEN
   MessageBox("Mail Send", 'Mail not sent')
   RETURN
END IF

mSes.mailLogoff()
DESTROY mSes

 

Accepted Answer
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 28 December 2018 20:10 PM UTC
  2. PowerBuilder
  3. # Permalink

Chris' SMTP example is based on a copy of my EmailSMTP example from 2012. It won't work with GMail because he didn't include cl32.dll which is an open source encryption library I used. I'm not even sure the latest version from my website still works with GMail.

You would be better off using the PBNISMTP example I linked to.

http://www.topwizprogramming.com/pbnismtp.html

 

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 1 January 2019 23:26 PM UTC
  2. PowerBuilder
  3. # 1

As for the other solutions offered here: beware of antivirus blocking your ports.

I once used Rolands smtp sample code and McAffee was blocking "attacks by worms …or something similar", meaning it would block port 25. We had to add our powerbuilder program to the list of exceptions of McAffee to get things working. (by the way you would also find Outlook.exe already added to that list, so it seems to be a common thing).

Comment
  1. Roland Smith
  2. Wednesday, 2 January 2019 00:38 AM UTC
You should have better results with this one:

http://www.topwizprogramming.com/pbnismtp.html



Port 25 is for unencrypted email. Encrypted connections will use port 465 or 587.
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 3 January 2019 00:40 AM UTC
Yes, I'll will check that version out, thanks Roland. (we use outlook, but do need also an Office independent version so that's great).
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 1 January 2019 23:23 PM UTC
  2. PowerBuilder
  3. # 2

We use MS Outlook to send our emails. Before we had the option of sending with (simple) MAPI. That somehow gave us a lot of problems from pb 12.6 onwards. We tried with all the INI settings, it just doesn't work right anymore.

Now we still use MAPI, but only to show the Address Book, since the MAPI version has the advantage of bringing that window to the front (instead of blinking in the toolbar like when using OLE and having the need for users to first notice that and then click on the blinking icon it to bring the list to the front).

If I remember well, the send simply freezes, so for that we use OLE.

Anyway one change we had to make was to add the default profile name and an empty string for the password to the mailLogon() call:

// Create a mail session
 mSes = CREATE Mailsession

 // Log on to the session
 // Trident 1 11/08/15 underlying changes to MAPI made by SAP
mRet = mSes.mailLogon(gnv_app.is_defaultprofile, "")

 

Another thing I suppose you already know, is that for gmail you have to enter the configuration of your account and allow "less secure apps":

https://devanswers.co/allow-less-secure-apps-access-gmail-account/

 

HIH,

MiguelL.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 28 December 2018 21:22 PM UTC
  2. PowerBuilder
  3. # 3

Hi Gimmy;

  I guess for GMail in today's world ... we should be using the Google RESTful API vs the old iMAP or SMTP protocols ...

FYI:  https://developers.google.com/gmail/api/

Regards

Comment
  1. ATK Gimmy Susan
  2. Friday, 28 December 2018 21:32 PM UTC
you are right but,

too difficult for us.
  1. Helpful
There are no comments made yet.
ATK Gimmy Susan Accepted Answer Pending Moderation
  1. Friday, 28 December 2018 20:33 PM UTC
  2. PowerBuilder
  3. # 4
Thanks Roland for your contribution.
I'm trying with your application 'pbnismtp', but I'm still in the mud.
it does not work.
I enclose configuration and error message.

=(
Attachments (1)
Comment
  1. Roland Smith
  2. Friday, 28 December 2018 20:39 PM UTC
Gmail doesn't accept connections on port 25. Try 587 instead.
  1. Helpful
  1. ATK Gimmy Susan
  2. Friday, 28 December 2018 20:52 PM UTC
i try to set:

CONNECTION TYPE: SSL/TLS

PORT: 587



the result at line is -4

// send the email

li_rc = ln_smtp.Send()



i have a message:

token provided to the function is invalid
  1. Helpful
There are no comments made yet.
ATK Gimmy Susan Accepted Answer Pending Moderation
  1. Friday, 28 December 2018 19:58 PM UTC
  2. PowerBuilder
  3. # 5

Hi Chris.

I try to use your application 'STD_FC_SMTP_v1.0.0.3_PB12.1_Classic_B6518_2015-12-22'

but it does not send mail.

( look image down )

 

p.s.

i try with both setting in PB.INI

Attachments (1)
Comment
  1. ATK Gimmy Susan
  2. Friday, 28 December 2018 20:05 PM UTC
This is the file 'SMTP_Trace.txt'





of_SendMail Start: 28/12/2018 21:05:32



220 smtp.gmail.com ESMTP d4sm37980370wrp.89 - gsmtp



HELO NBATK43-PH



250 smtp.gmail.com at your service



AUTH LOGIN



530 5.7.0 Must issue a STARTTLS command first. d4sm37980370wrp.89 - gsmtp
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 28 December 2018 20:27 PM UTC
Looks like GMail is expecting you to use the TLS protocol on Port 587.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 28 December 2018 17:37 PM UTC
  2. PowerBuilder
  3. # 6

Hi Gimmy;

  PB2017 uses Extended MAPI by default. If your mail provider does not support this, you would need to change the setting by updating your PB.INI file, as follows:

[PB]
; No = Extended MAPI
UseSimpleMAPI=yes

That would put your App's back to the using the older protocol. If that works, then you would need to create your own PB.INI file in the App's folder for the EXE to work as well. Then don't forget to deploy the App's PB.INI with your EXE into production.

HTH

Regards ... Chris

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 28 December 2018 16:44 PM UTC
  2. PowerBuilder
  3. # 7

You didn't say what error or non-action you are getting.

Maybe you should use SMTP instead:

http://www.topwizprogramming.com/pbnismtp.html

SMTP sends the email directly to the mail server. The built in functions you are trying to use go through your mail client.

SMTP won't put a copy in your Outlook Sent Items folder. You could however send a BCC to yourself and add a rule in Outlook to move them from Inbox to Sent Items.

Comment
  1. ATK Gimmy Susan
  2. Friday, 28 December 2018 17:11 PM UTC
Hi Roland

The problem is that all 'mRet says me ok, but the mail does not start.

  1. Helpful
  1. Roland Smith
  2. Friday, 28 December 2018 18:05 PM UTC
For MAPI or Extended MAPI to work, you have to have a mail client that supports it that is also the same bitness as the PowerBuilder app.
  1. Helpful
There are no comments made yet.
ATK Gimmy Susan Accepted Answer Pending Moderation
  1. Friday, 28 December 2018 16:22 PM UTC
  2. PowerBuilder
  3. # 8

Ecosystem:  Windows 10

Comment
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.