Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Oct 2003
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Outlook Paste (Outlook)

    Please forgive me as this is the VERY first VB code I have ever tried to create. I am trying to simply create a macro and assign it to a button. The macro is simply opening a new e-mail, creating the send to, the subject, and a simple body text, then pasting something from the clipboard and then send. Not rocket science right?

    I get all aspects of this thing up until the PASTE function. Here is my current code, could someone tell me how to just execute a paste function? As always thank you for the help

    Sub CIS()
    Dim msg As Outlook.MailItem
    Set msg = Application.CreateItem(olMailItem)
    msg.To = "testemail@helpme.com"
    msg.Subject = "This is the subject"
    msg.Body = "I will put the body text here"

    ***this is where I am stuck*******

    msg.Send

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook Paste (Outlook)

    I assume that you want to paste something from the clipboard into the body of the e-mail.
    Do the following in the Visual Basic Editor:
    - Select Insert | UserForm.
    - You can discard the userform immediately, it won't be needed any more.
    - We only needed it to be able to use a certain object.
    - Replace the line

    msg.Body = "I will be the body text here"

    with

    Dim objData As New DataObject
    objData.GetFromClipboard
    msg.Body = "This is the body text. " & objData.GetText

    You can customize this, of course.

  3. #3
    Lounger
    Join Date
    Oct 2003
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook Paste (Outlook)

    Hans,

    That worked perfectly.

    Could you also tell me how to paste a screenshot? The pasting of text works perfect but of course it will not work for an image. Any suggestions?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook Paste (Outlook)

    There is no support in Outlook VBA for pasting images into mail messages. You'd have to save the image to disk and use the rather exotic code from To add an embedded image to an HTML message in Microsoft Outlook using code to manipulate the HTMLBody property of the message.

  5. #5
    Lounger
    Join Date
    Oct 2003
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook Paste (Outlook)

    Thanks for the help. The original code is working great and will do what I need. Thanks 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
  •