Consulting

Results 1 to 4 of 4

Thread: Solved: Notifying changes in Post

  1. #1

    Solved: Notifying changes in Post

    Hi, I'm sure this is dead simple but I'm completely confused by Outlook and am struggling to work out what is called what and... well, I need help.

    I have a custom IPM.Post form and on it are three check boxes. All I want is for a mail to be sent when these check boxes change their value. To simplify installation I need the code to be embedded with the form as a script, not an Outlook VBA routine.

    So far I have this:

    [VBA]
    Sub Item_CustomPropertyChange(ByVal Name)
    Set olApp = CreateObject("Outlook.Application")
    Set olNameSpace = OlApp.GetNameSpace("MAPI")

    Select Case Name
    Case "Collection booked"
    Set MailNoti = OlApp.CreateItem(0)
    MailNoti.To = "jon@mycompany.com"
    MailNoti.Subject = "Collection Booked"
    Message = "Your Shipping Request to has been booked!"
    MailNoti.Body = Message
    MailNoti.Send
    End Select

    End Sub
    [/VBA]

    Which works (I'll add more Case statements once I've got one working!), but what I really need is a) for the email address to be the original poster of the form, b) for the Message body to include the Subject field on that form (as part of a sentence).

    I know I need to reference the form in some way to find the 'sender' and the subject but I'm lost as to how. Can anyone help?

    FYI the form is called IPM.Post.ShipReq
    Jon

  2. #2
    Nobody got any advice on this?

    Jon

  3. #3
    I try to avoid VBScript whenever I can, but I can understand how it is desirable in this situation.

    First of all, using a macro to retrieve a sender's email address in Outlook can be a painful and ugly process. The SenderEmailAddress property for an item is only available in Outlook 2003 and later, and thanks to a security patch, chances are you'll see a popup window asking for explicit authorization to share those addresses with the "unknown program" for a few minutes. In this case, you're either stuck with manually clicking the Yes button each time or you'll need to research and install additional software to bypass or automate this popup for you.

    Secondly, my personal preference is to retrieve item information from the item's object, not from the form. To do this, you can retrieve the object reference from the Inspector object (the form), and since that Inspector is already open, you can find the Application's ActiveInspector like so:
    [VBA]
    Set objPostItem = Application.ActiveInspector.CurrentItem
    MailNoti.To = objPostItem.SenderEmailAddress
    MailNoti.Body = objPostItem.Subject & vbCrLf & Message
    [/VBA]

    I hope that helps!

  4. #4
    Chocobo, that's the trick!

    Thanks muchly, that's the pointer I needed. No excuse for not getting the project finished now.

    Jon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •