[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1615
  • Last Modified:

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?
0
BooBoo2004
Asked:
BooBoo2004
1 Solution

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now