Link to home
Start Free TrialLog in
Avatar of BooBoo2004
BooBoo2004

asked on

How do I set sender's address in PB10 using Outlook redemption?

I have installed and able to send emails from a PB10 application.  I am able to bypass the security prompt (good bennie), but I need to set pr_sender_email_address value to "somebody@domain.com".  I have found code that allows me to view the sender's email address, but I need to set it.

The code that I have so far is:

//variables
string ls_sendto, ls_subject, ls_message, ls_copyto
boolean lb_goodtosend
integer li_array, rc
oleobject oleSafeMailItem
oleobject oleTmp
oleobject oleOutlook
oleobject oleNameSpace

//First we need to capture the subject line and the mail text
ls_sendto = Trim(sle_sendto.Text)
ls_copyto = Trim(sle_copyto.Text)
ls_subject = Trim(sle_subject.Text)
ls_message = Trim(mle_message.Text)

//Now we need to know if we can send the data
lb_goodtosend = True

If ls_sendto = "" Then
      lb_goodtosend = False
End If

If ls_subject = "" Then
      lb_goodtosend = False
End If

If ls_message = "" Then
      lb_goodtosend = False
End If

If lb_goodtosend = True Then

      oleOutlook = create oleobject
      rc = oleOutlook.ConnectToNewObject("outlook.application")
      
      If rc = 0 Then
            oleNameSpace = oleOutlook.GetNameSpace("MAPI")
            oleNameSpace.Logon("outlook", "G3tMyM@il01$", true, true)

            oleSafeMailItem = create oleobject
            rc = oleSafeMailItem.ConnectToNewObject("Redemption.SafeMailItem")

            If rc = 0 Then
                  oleTmp = create oleobject
                  oleTmp = oleOutlook.CreateItem(0)
                  oleSafeMailItem.Item = oleTmp
                  oleSafeMailItem.Recipients.Add(ls_sendto)
                  oleSafeMailItem.Recipients.ResolveAll
                  oleSafeMailItem.Subject = ls_subject
                  oleSafeMailItem.Send

            Else
                  MessageBox("Mail Error", &
                        "Your email could not be sent.  Please contact IT.~r~n" + &
                        "The SafeMailItem  - ConnectToNewObject~r~n" + &
                        "failed with a return code of " + String(rc) + ".", &
                        StopSign!, &
                        Ok!)
            End If
      Else
            MessageBox("Mail Error", &
                  "Your email could not be sent.  Please contact IT.~r~n" + &
                  "The Outlook Application  - ConnectToNewObject~r~n" + &
                  "failed with a return code of " + String(rc) + ".", &
                  StopSign!, &
                  Ok!)
      End If

End If

if isValid(oleSafeMailItem) then
      destroy oleSafeMailItem
End If

if isValid(oleNameSpace) then
      oleNameSpace.logoff()
      destroy oleNameSpace
end if

if isValid(oleOutlook) then
      oleOutlook.DisconnectObject()
      destroy oleOutlook
end if

I think that I need to use MapiUtils from Outlook Redemption, but I do not know how to code it.  Any suggestions out there?
ASKER CERTIFIED SOLUTION
Avatar of diasroshan
diasroshan
Flag of Kuwait image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial