Computing Staff
  • 2

VB Code To Open Outlook And Send Compose Email

  • 2

Hello all,

I have scoured the internet and haven’t found a code I understand for this. What I want is real simple.. a VB code to open outlook (no address or subject necessary), attach a file and that’s it. This code can be preferably executed from a button/link.

Share

1 Answer

  1. Googled and found this:
    Dim objOutl
    Set objOutl = CreateObject(“Outlook.Application”)
    Set objMailItem = objOutl.CreateItem(olMailItem)
    objMailItem.Display
    strEmailAddr = “me.me@you.com”
    objMailItem.Recipients.Add strEmailAddr
    objMailItem.Body = “body here”
    objMailItem.Attachments.Add “file.xml”
    Set objMailItem = nothing
    Set objOutl = nothing
    Replace file.xml with your file and strEmailAddr variable to your recipient address.

    I didn’t test it as I do not have Outlook on this box.

    Tony

    • 0