Greetings all,
It's been a LONG since I posted to a PowerBuilder Newsgroup (or whatever this is).
I think I have a simple problem. I hope. For years I have used some code to save a datawindow as a PDF attachment and email it as an attachment.
So now I have a new project and for the life of me, I cannot get it to work.
I would really appreciate it if someone could take a look at the code and help me.
Question 1: Can I finally get rid of helper.dll to map the path to the virtual path (e.g., c:\inetpub\wwwroot\mywebform\u7ru84ir93ur829o\c\mypdf.pdf)
Comment 1: My code compiles and displays the message ("Your receipt has been emailed to the requested recipient at " + user_id) which I think means that the returncode from **returncode = dw_1.SaveAs(filepathname,PDF!,false)** is not returning a value of 1.
user_id = trim(user_id)
string bodytext
bodytext = 'Dear PDF Viewer, ' + '~r~n' + '~r~n' + 'Please find attached the requested manifest in PDF format.' + '~r~n' + '~r~n' + 'Thank you,' + '~r~n' + '~r~n' + 'Ajax Operations' + '~r~n' + '1-888-888-8888'
string filename
string filepathname
//create the path to use LATER for the attachment
#if defined PBWEBFORM then
//this does not work!!
//filepathname = Helper.PBInternal.ConvertVFS2ActualPath("c:\MyPDF For-" + string(today,"MM-DD-YYYY") + ".pdf")
filepathname = MapVirtualPath("c:\
MyPDF For-" + string(today,"MM-DD-YYYY") + ".pdf")
//create the path and filename to use NOW to distill and save the file in the virtual directory
filename = "c:\MyPDF For-" + string(today,"MM-DD-YYYY") + ".pdf"
long returncode
returncode = dw_1.SaveAs(filename,PDF!,false)
if returncode = 1 then
string subject
subject = "MyPDF For-"+string(today,"MM-DD-YYYY")
string fromaddresstext
fromaddresstext = "abc@abc.com"
System.Net.mail.MailMessage message
message = create System.Net.mail.MailMessage
message.subject = subject
message.body = bodytext
System.Net.Mail.MailAddress fromaddress
fromaddress = create System.Net.Mail.MailAddress("abc@abc.com", "PDF Operations")
message.From = fromAddress
System.Net.Mail.MailAddress toaddress
message.To.Add(user_id);
//TEMPORARILY COMMENTED OUT UNTIL WE CAN GET THE PATH THING FIGURED OUT!!
System.Net.Mail.Attachment attach
attach = create System.Net.Mail.Attachment(filepathname,"application/pdf");
//Helper.Mail.AddAttachment(message, attach) //THIS USED TO WORK
message.Attachments.Add(attach); //MAYBE THIS WILL WORK
System.Net.Mail.SmtpClient smtpclient
smtpclient = create System.Net.Mail.SmtpClient
smtpclient.host = "webapp.abc.com"
smtpclient.port = 25
smtpclient.send(message)
mle_1.text = "Your receipt has been emailed to the requested recipient at " + user_id
else
mle_1.show()
mle_1.text = "Sorry, there was a problem generating the file."
destroy message
destroy smtpclient
end if
#end if