0

i have Outlook plugin that open popup window after user click on "Send" button. In this window user choose email sender. So i use "ItemSend" event and if i change "SendOnBehalf" property inside this event than Outlook just overite my changes so i should do it before "ItemSend" i found only one event before "ItemSend" it's "BeforeCheckNames" but i can't use it because than my popup window open many times. So my last idea maybe i can hide standard button "Send" and put my button for send email than i can make my changes and after that say email.Send(). I found that this question was asked before Replace the Outlook 2010 Send-Button? but there is no answer. Maybe you have any ideas? Thank you for help

Community
  • 1
  • 1
masta
  • 69
  • 1
  • 13

3 Answers3

1

No, the Send button cannot be hidden. Why not add a combobox to the ribbon and let the user specify the sender before sending? You can set SendOnBehalf as soon as the user selects a value from the combobox.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
1

Alternatively you could amend your ItemSend code. The SentOnBehalfOfName will stick to a copied item.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Dim copiedItem As MailItem

If Item.Class = olMail Then

    Set copiedItem = Item.Copy

    copiedItem.SentOnBehalfOfName = "someone@someplace.com"
    'copiedItem.Display
    copiedItem.Send

    Item.Delete
    Cancel = True

End If

    Set copiedItem = Nothing

End Sub
niton
  • 8,771
  • 21
  • 32
  • 52
  • The ItemSend event handler will be called recursively... Each time you call the Send method, so basically we need to check out the property value first. And only if it doesn't have any value we can set it. – Eugene Astafiev Jul 08 '15 at 17:16
  • @Eugene. If there is recursion, but it is not recursive for me. – niton Jul 08 '15 at 18:32
1

Another option is to use the Replacement or Replace-all form region types that allow to replace the standard form completely.

  • Replacement - Adds the form region as a new page that replaces the default page of an Outlook form.
  • Replace-all - Replaces the whole Outlook form with the form region.

See Creating Outlook Form Regions for more information.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45