Consulting

Results 1 to 4 of 4

Thread: Custom button to modify body of email being composed

  1. #1
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location

    Custom button to modify body of email being composed

    I often get small requests throughout the day to add items to our database, so when I am done, I send a reply back to the person saying "done" or something similar.

    I probably do this about 10 times a day, so was thinking I could just create a macro to put this into the body of the email. Something like:

    [VBA]Sub DoneText()

    item.Body = "Done " & vbclrf & vbCrLf & item.Body

    End Sub[/VBA]

    This doesn't work, as it is saying "Object required". I have tried adding teh following to the code:

    [VBA]Dim OutlookApp As Object
    Dim MItem As Object
    Set OutlookApp = CreateObject("Outlook.Application")

    Set MItem = OutlookApp.CreateItem(0)[/VBA]

    But I am not creating a new email object, I am wanting to find the current object and "fiddle" with it.


    Any help would be appreciated
    -Once my PC stopped working, so I kicked it......Then it started working again

  2. #2
    VBAX Tutor Mavyak's Avatar
    Joined
    Jul 2008
    Posts
    204
    Location
    I think this will get it:

    [VBA]Set MItem = ActiveInspector.CurrentItem[/VBA]

  3. #3
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location
    That worked perfectly, thank you


    Now I have another problem. I compose email in HTML format (so I can use my signature and so there is proper formating), whereas this code turns it all into rich text (or so I think). Is it possible to keep the original formating?
    -Once my PC stopped working, so I kicked it......Then it started working again

  4. #4
    VBAX Mentor OTWarrior's Avatar
    Joined
    Aug 2007
    Location
    England
    Posts
    389
    Location
    Nevermind, Just found that it can be done by using:
    [VBA]item.HTMLBody[/VBA]
    instead of
    [VBA]item.Body[/VBA]
    -Once my PC stopped working, so I kicked it......Then it started working again

Posting Permissions

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