cancel
Showing results for 
Search instead for 
Did you mean: 

Appeon / PB12.5 / Roland's Email Code / Firewall?

Former Member
0 Kudos

Greetings All,

I have an Appeon Web Application that sends emails using Roland's code.

I am deploying to server mobile.ftl.com.

When I run the application using http://mobile.ftl.com/affiliate_portal the application sends the email without a problem.

But when I run the application using http://ap.flightviewlimo.com/affiliate_portal the return code from lb_Return = gn_smtp.of_SendMail().  The text of the error is "An unknown error as occurred."

Chris Pollach has suggested in the past to simply create a web service to handle this.  And I might have to now, but I was hoping there is something simple to change to make it work.

I 'thought' this code would be running on the server so there would be no need to authenticate if that is the issue.

I have edited my SMTP Server settings on webapp3.ftl.com to allow for traffic from mobile.ftl.com using its IP address.

Any pointers would be greatly appreciated!!

Thank you!!

Paul

string return_code

message_prefix = "Affiliate " + sp_id + " has made a request to override the original quoted amount for this trip.  They would like to close this trip with details as shown in the bottom of this email." + &

  '~r~n' + 'Affiliate Job ID: ' + affiliate_job_id + &

  '~r~n' + 'Override Requested By: ' + userid + &

  '~r~n' + &

  '~r~n' + 'To APPROVE the Override Request, click on the link below' + &

  '~r~n' + &

  '~r~n' + 'http://mobile.ftl.com/trip_closeout_override/default.aspx?PBCommandParm=' + confo + '%20' + 'approved' + &

  '~r~n' + &

  '~r~n' + 'To DECLINE the Override Request, click on the link below' + &

  '~r~n' + &

  '~r~n' + 'http://mobile.ftl.com/trip_closeout_override/default.aspx?PBCommandParm=' + confo + '%20' + 'declined' + &

  '~r~n' + &

  '~r~n' + 'The following is the users reason for requesting the override:' + &

  '~r~n' + &

  '~r~n' + ''

String ls_body, ls_server, ls_uid, ls_pwd

String ls_filename, ls_port, ls_encrypt, ls_errormsg

Integer li_idx, li_max

Boolean lb_html, lb_Return

UInt lui_port

string subject

subject = "Request To Override Affiliate Charges: Confo: " + confo

ls_server = 'webapp3.ftl.com'

lb_html = False

string m_message

m_message = message_prefix + reason_text + notepad_entry

lui_port = 25

gn_smtp.of_SetPort(lui_port)

gn_smtp.of_SetServer(ls_server)

gn_smtp.of_SetLogFile(false, "")

gn_smtp.of_SetDebugViewer(false)

gn_smtp.of_SetSubject(subject)

gn_smtp.of_SetBody(m_message, lb_html)

gn_smtp.of_SetFrom(userid, sp_id)

gn_smtp.of_AddAddress("billing@flightviewlimo.com", "Billing")

gn_smtp.of_AddAddress("paulm@flightviewlimo.com", "IT") //uncommented on 7/24

gn_smtp.of_AddAddress("jasonr@flightviewlimo.com", "IT") //added on 7/24

lb_Return = gn_smtp.of_SendMail()

If lb_Return Then

  MessageBox("Trip Closeout Request", "Request successfully sent to Billing.")

Else

  MessageBox("Trip Closeout Request", gn_smtp.of_GetLastError())

End If

If lb_Return Then

  return_code = "OK"

Else

  return_code = "ERROR"

End If

return return_code

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Paul;

FWIW: You have to keep in mind that any PB code you transcribe into Appeon Web is translated into JScript and run within the client's web browser. Thus, the SMTP email requests will be at the mercy of the client PC's web browser, configuration & security restrictions. 

Regards ... Chris

Former Member
0 Kudos

Thanks, Chris!!

I guess i thought that the code above, running as a function, would be server side code that would called from the browser.  There is no authentication required.

Does that mean it will not work or some additional work has to be done?

If I do create an email web service to run on the same server, will I still have challenges getting the Javascript to call it?

Paul

Former Member
0 Kudos

I'm sure that you can get it to work by tweaking the clients environment (if their system people allow it). However, you'll have to overcome system policy, security, and/or configuration issues while troubleshooting each client's SMTP error(s).

The nice thing about the Web Service approach is that your placing the SMTP logic solidly on the server side. So once you get your IIs server SMTP ready, your good to go for any client. You'll need to think about the design though whether all the emails come from your company (if your hosting the Appeon Server - say in a cloud scenario) or the Appeon Server will be installed at your clients site (hence using their SMTP corporate service).

  As far as calling the Web Service from your Appeon applications, you can do this via standard WebService client proxies that you would use in any native PB Classic application or ... Use the WS DataWindow (my favourite).

  Don't forget that I have a free WS Framework that you can use. Also, I have many WS examples and the OrderEntry example application that runs as an Appeon Web application provides a WS component and calls it using a WS DW as a good coding example to leverage how to start using such a tandem object pair.

HTH

Former Member
0 Kudos

Thanks Chris,

I had an email web service in the works after your previous suggestion to do it as a web service.

So I created a .net email web service and deployed it to mobile.ftl.com.

I created a WS DW which works fine when I test it.  This WS DW uses a URL that comes through the firewall.

Anyway, when I run it, I get -1 for the number of rows returned from the WS DW running the application in 32 bit mode on my desktop.

I am not sure how to determine what is going wrong that the DW WS (or something  else) is not working.

Thanks!!

Paul

string return_code

message_prefix = "Affiliate " + sp_id + " has made a request to override the original quoted amount for this trip.  They would like to close this trip with details as shown in the bottom of this email." + &

  '~r~n' + 'Affiliate Job ID: ' + affiliate_job_id + &

  '~r~n' + 'Override Requested By: ' + userid + &

  '~r~n' + &

  '~r~n' + 'To APPROVE the Override Request, click on the link below' + &

  '~r~n' + &

  '~r~n' + 'http://mobile.ftl.com/trip_closeout_override/default.aspx?PBCommandParm=' + confo + '%20' + 'approved' + &

  '~r~n' + &

  '~r~n' + 'To DECLINE the Override Request, click on the link below' + &

  '~r~n' + &

  '~r~n' + 'http://mobile.ftl.com/trip_closeout_override/default.aspx?PBCommandParm=' + confo + '%20' + 'declined' + &

  '~r~n' + &

  '~r~n' + 'The following is the users reason for requesting the override:' + &

  '~r~n' + &

  '~r~n' + ''

string subject

subject = "Request To Override Affiliate Charges: Confo: " + confo

string m_message

m_message = message_prefix + reason_text + notepad_entry

long rows

string nullvalue

SETNULL(nullvalue)

datastore call_email_ws

call_email_ws = create datastore

call_email_ws.dataobject = 'dw_send_email_via_email_webservice'

call_email_ws.settransobject(sqlca)

rows = call_email_ws.retrieve("password", "billing@flightviewlimocom", "Flight View Billing", "billing@flightviewlimo.com", "paulm@flightviewlimo.com", "jasonr@flightviewlimo.com",  nullvalue,  nullvalue,  nullvalue,  nullvalue,  nullvalue,  nullvalue, subject, m_message)

messagebox("rows",string(rows))

if rows = 1 then

  return_code = trim(call_email_ws.getitemstring(1, "returnvalue"))

end if

messagebox("return_code",return_code)

If return_code = "OK" Then

  MessageBox("Trip Closeout Request", "Request successfully sent to Billing.")

Else

  MessageBox("Trip Closeout Request", "Problem sending email.  Please send screenshot to support@flightviewlimo.com.  Return Code: " + return_code)

End If

If return_code = "OK" Then

  return_code = "OK"

Else

  return_code = "ERROR"

End If

destroy call_email_ws

return return_code

Former Member
0 Kudos

Could it be that I am missing some web service datawindow deployment files?

Since I am running it under PB 12.5 IDE, I thought that should not be the case.

Former Member
0 Kudos

Hmmm...

Turns out the WS DW works fine when I have all of the parameters populated with data.

So when I try to run it and do not pass a value for cc_email or bcc_email, it pukes.

I tried check .Net nullable types hoping that would make the parameters optional, redeployed the service and recreated the WS DW, but no help there.

Ugh.

Former Member
0 Kudos

Thanks everyone.  All working now.

I had  to chop out some arguments like to_address_2, to_address_3, cc_address 1, 2,3 and bcc_address 2 and 3 because I could not figure out how not to pass null.

I guess I could have defaulted to "no_email" and interpreted that in the web service, but it was getting to be a hassle and there are other projects to get done. 

Thanks!!

Paul

Answers (1)

Answers (1)

Former Member
0 Kudos

I queue my emails in the database and have server batch program read the queue,  then deliver to smtp.  You can have the code if you want. Used same queue table to send sms at some stage.

Former Member
0 Kudos

That sounds great, Lars. 

pemurray at interrasys.com

Out of curiosity, does it handle attachments?  I am not doing attachments in this project, but expect to need that soon.

Thank you!!

Paul

Former Member
0 Kudos

I used the database queue method. It is a lot faster to insert a row into a table than send an email.

Attachments would probably have to go in a separate table using a blob column.

Former Member
0 Kudos

Hi Roland;

  I've used your approach with a PB Web Service. The PB or Appeon Web or Mobile application writes to a queue table that includes another Blob table & column for the attachments. The Web Service is called after the queue row is inserted and the DB transaction is committed.

The WS component then has a lot more flexibility in formatting the email(s) and attachment(s). The big thing I also like is the WS can return a completion code & status to the client while posting more details to the email queue table as well. This makes it great when tracing back emailing issues when I have problems or for audit trail purposes.

Regards ... Chris

Former Member
0 Kudos

Hi Paul,  Have sent email. Lars