+ Reply to Thread
Results 1 to 15 of 15

Opens Outlook from Excel using VBA and send emails

  1. #1
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Opens Outlook from Excel using VBA and send emails

    Hi,

    I have the following code, and while it is working, but I would like to tweak it around to suit my needs:

    Please Login or Register  to view this content.
    What I want:

    Have the macro open up an instance of Outlook and manually fill in what goes in the body. The recipient's email address and the subject lines can use what's in the code above.

    The code will send the current active workbook out as an attachment, and I would like to keep this feature.

    Is this doable via a macro?

    Thanks
    Last edited by Lifeseeker; 02-10-2012 at 03:42 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Opens Outlook from Excel using VBA and send emails

    Anybody able to assist on this one?

    Thanks

  3. #3
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Opens Outlook from Excel using VBA and send emails

    Any one able to assist?

    The current code opens outlook and passes what's in the code to corresponding fields in Outlook.

    However, what I would like it to work is:

    1) Open outlook and fill the corresponding fields in Outlook
    2) have user manually hit "Send" button in Outlook.
    3) have the macro close that instance of Outlook.

    Is this doable?

    Please Login or Register  to view this content.
    Thanks
    Attached Files Attached Files

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Opens Outlook from Excel using VBA and send emails

    You would need to change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    to pop the email up for the user.

    I would not recommend quitting Outlook as you don't know whether it was already opened by the user.
    Good luck.

  5. #5
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Opens Outlook from Excel using VBA and send emails

    Wow nice! That's an easy fix.

    When it opens the Outlook, it actually opens the "Appointment" window?

    Is there any way to have it open the "Message" window with email signatures and everything?

    Thanks

    Please Login or Register  to view this content.

  6. #6
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Opens Outlook from Excel using VBA and send emails

    That is because you created an appointment item! This line
    Please Login or Register  to view this content.
    shoudl be
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Opens Outlook from Excel using VBA and send emails

    wow nice, I wasn't aware of that.

    so I guess

    Please Login or Register  to view this content.
    by default creates appointments?

    Thanks

  8. #8
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Opens Outlook from Excel using VBA and send emails

    oh and.....I guess the code just creates a new instance of Outlook and from there displays the email window.

    What if....the Outlook is already open? I don't want it to create a new instance of Outlook if the Outlook is already running. In this case, is it possible to have it display an new email window from existing Outlook application?

  9. #9
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Opens Outlook from Excel using VBA and send emails

    It will use an open outlook instance.
    The 0 means mail item, 1 means appointment.

  10. #10
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Opens Outlook from Excel using VBA and send emails

    Quote Originally Posted by OnErrorGoto0 View Post
    It will use an open outlook instance.
    The 0 means mail item, 1 means appointment.
    ah good to know indeed.

    thank you

  11. #11
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Opens Outlook from Excel using VBA and send emails

    Hi,

    I am wondering if I can put a check in the code and have it first check to see if the Outlook is already open. If the Outlook is already running, then just open up a new email window from it and execute the rest of the code. If Outlook is not yet running, first start Outlook and from it open up an "Email" window and execute the rest of the code.

    Is this possible?

    THanks

  12. #12
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Opens Outlook from Excel using VBA and send emails

    Is it not doing that anyway?

  13. #13
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Opens Outlook from Excel using VBA and send emails

    Sorry should have been more clearer:

    Currently, if the Outlook is already running, while the code does open the email window, it has to open a new instance of the Outlook along with it. I think this is because the code itself actually creates a new Outlook object and from it creates an appointment type of "0"?

    So, I guess the more times users click on the button, the more instances of Outlook are created, and this might be a problem down the road now as I see it. (users probably just want to click on it once and if the Outlook is already running, open the appointment type of 0 instead of creating a new Outlook object). (Typically, users will have both Excel and Outlook running at the same time here...)

    Do you have any suggestions on this?

    Thanks

  14. #14
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Opens Outlook from Excel using VBA and send emails

    Ah, I missed the fact you have
    Please Login or Register  to view this content.
    in your code for some reason. Remove that.

  15. #15
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Opens Outlook from Excel using VBA and send emails

    Nice!

    Yeah, I believe I added that shell statement initially because I wasn't understanding how the code creates the Outlook as an object, but thank you and it's working like a charm.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1