josephbarron
asked on
Sending Outlook Emails with PowerBuilder
I have a client that has a database in SQL Server. It has a front end PowerBuilder application that I developed. They use this for Membership management and send emails regurlarly. A new VP has come on board that wants to send Emails through Outlook, but wants the Body to be personalized to recipient.
Dear John:
Your company, Verizon, Inc. is a very important member....
They also want to add attachments and set the subject line. The data for the merge is in SQL Server and I have the perfect spot to put the button control. Problem is, I don't know a good resource for connecting to Outlook 2003, loading the information and pressing the send button, in an automagical way.
Any guidence would be greatly appreciated.
Regards,
Dear John:
Your company, Verizon, Inc. is a very important member....
They also want to add attachments and set the subject line. The data for the merge is in SQL Server and I have the perfect spot to put the button control. Problem is, I don't know a good resource for connecting to Outlook 2003, loading the information and pressing the send button, in an automagical way.
Any guidence would be greatly appreciated.
Regards,
ASKER
Actually found the solution using the Redemption DLL solution. It works around most of the issues with OLE connections to Outlook and the security blocks that MICrosoft has put in place to plug holes.
http://www.dimastr.com/redemption/
Works real well and there are plenty of examples on this board of how to use it.
integer rc
oleobject oleSafeMailItem
oleobject oleTmp
oleobject oleOutlook
oleobject oleNameSpace
STRING ls_email, ls_company_name, ls_full_name, ls_path, ls_body_text, ls_checked
li_send_total = dw_details.rowcount()
FOR li_counter = 1 to li_send_total
ls_email = dw_details.getitemstring(l i_counter, "email")
ls_full_name = dw_details.getitemstring(l i_counter, "fullname")
ls_company_name = dw_details.getitemstring(l i_counter, "Company")
ls_body_text = wf_create_body(li_counter) // This function creates the body text using <FN> for first name, <LN> for last name, etc.
ls_path = TRIM(sle_attachment.text)
ls_email = "tom@company.com"
oleOutlook = create oleobject
rc = oleOutlook.ConnectToNewObj ect('Outlo ok.Applica tion')
oleNameSpace = oleOutlook.GetNameSpace('M API')
oleNameSpace.Logon('', '', true, true)
oleSafeMailItem = create oleobject
rc = oleSafeMailItem.ConnectToN ewObject(' Redemption .SafeMailI tem')
oleTmp = create oleobject
oleTmp = oleOutlook.CreateItem(0)
oleSafeMailItem.Item = oleTmp
oleSafeMailItem.Recipients .Add(LS_EM AIL)
oleSafeMailItem.Recipients .ResolveAl l
IF TRIM(sle_attachment.TEXT) = "" THEN
// No Attachment
ELSE
oleSafeMailItem.Attachment s.Add(TRIM (sle_attac hment.TEXT ))
END IF
oleSafeMailItem.Subject = trim(sle_subjectLine.text)
oleSafeMailItem.body = trim(ls_body_text)
oleSafeMailItem.Send
if isValid(oleSafeMailItem) then destroy oleSafeMailItem
if isValid(oleNameSpace) then
oleNameSpace.logoff()
destroy oleNameSpace
end if
if isValid(oleOutlook) then
oleOutlook.DisconnectObjec t()
destroy oleOutlook
end if
NEXT
http://www.dimastr.com/redemption/
Works real well and there are plenty of examples on this board of how to use it.
integer rc
oleobject oleSafeMailItem
oleobject oleTmp
oleobject oleOutlook
oleobject oleNameSpace
STRING ls_email, ls_company_name, ls_full_name, ls_path, ls_body_text, ls_checked
li_send_total = dw_details.rowcount()
FOR li_counter = 1 to li_send_total
ls_email = dw_details.getitemstring(l
ls_full_name = dw_details.getitemstring(l
ls_company_name = dw_details.getitemstring(l
ls_body_text = wf_create_body(li_counter)
ls_path = TRIM(sle_attachment.text)
ls_email = "tom@company.com"
oleOutlook = create oleobject
rc = oleOutlook.ConnectToNewObj
oleNameSpace = oleOutlook.GetNameSpace('M
oleNameSpace.Logon('', '', true, true)
oleSafeMailItem = create oleobject
rc = oleSafeMailItem.ConnectToN
oleTmp = create oleobject
oleTmp = oleOutlook.CreateItem(0)
oleSafeMailItem.Item = oleTmp
oleSafeMailItem.Recipients
oleSafeMailItem.Recipients
IF TRIM(sle_attachment.TEXT) = "" THEN
// No Attachment
ELSE
oleSafeMailItem.Attachment
END IF
oleSafeMailItem.Subject = trim(sle_subjectLine.text)
oleSafeMailItem.body = trim(ls_body_text)
oleSafeMailItem.Send
if isValid(oleSafeMailItem) then destroy oleSafeMailItem
if isValid(oleNameSpace) then
oleNameSpace.logoff()
destroy oleNameSpace
end if
if isValid(oleOutlook) then
oleOutlook.DisconnectObjec
destroy oleOutlook
end if
NEXT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If u check the PB examples u will find a good way to do what u want...
If u run PB examples,
expand the tree 'window controls'
under that there is RichPad RTE Control..
Check that out... it shows how to mail an RTE control... u can use the same to personalise and send a document.
Cheers,
Rosh