+ Reply to Thread
Results 1 to 11 of 11

VBA to send email with outlook

  1. #1
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    VBA to send email with outlook

    Hi All,

    I was wondering whether someone can help me out with the below.

    Basically I have this VBA which copies a sheet from an active workbook into a newly created workbook:


    HTML Code: 



    I would like to include a further line to the VBA which would e-mail the newly created workbook as follows:


    To: "insert e-mail address"
    CC: "insert e-mail address"
    Subject: Deadline Report
    Text: "Kindly find attached the deadline report for the month";
    "Thanks and Regards"


    Once sent the newly created workbook can be closed without saving.

    Can someone please help me with the above? Would really appreciate your help!

    Best Regards

    Keibri
    Last edited by Keibri; 03-08-2018 at 03:22 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VBA to send email with outlook

    Paste the following into a routine module. This macro saves the ACTIVE SHEET as a separate workbook, attaches to an email that is created.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    Re: VBA to send email with outlook

    Hi Logit!!

    Thanks for your message!!

    The code is perfect!

    I would like to ask two questions if possible:
    -would it be possible to amend the code so as rather than the activesheet I can specify which sheet I want to be sent
    -also the code stops at attaching the email. Would it be possible to have the email sent?

    Thanks a lot !!

    Keibri

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VBA to send email with outlook

    .
    To have the email autosend without first seeing it ... change .Display to .Send

    Re: Which sheet to attach ... will the sheet always be the same (i.e., Sheet1 or Sheet2, etc?) ... or will the sheet possibly change from time to time ?

  5. #5
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    Re: VBA to send email with outlook

    Hi Logit thanks for that!!

    The sheet will always be the same! !

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VBA to send email with outlook

    .
    Since the sheet will always be the same, create the command button on the sheet you want to attach to the email and it will always send that sheet only.

  7. #7
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    Re: VBA to send email with outlook

    Great!! Thanks a lot for your help!

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VBA to send email with outlook

    You are welcome.

  9. #9
    Forum Contributor
    Join Date
    02-09-2015
    Location
    malta
    MS-Off Ver
    Microsoft 365
    Posts
    383

    Re: VBA to send email with outlook

    Thanks man. Just in case, don't know if it's a big inconvenience. If I have to launch the macro from a different sheet then the sheet I want to send. Could this be done please?! thanks a lot!

  10. #10
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VBA to send email with outlook

    .
    These two macros were created in ThisWorkbook :

    Please Login or Register  to view this content.
    This macro was created in a routine module :

    Please Login or Register  to view this content.
    Then a UserForm was created and this code was placed in the UserForm :

    Please Login or Register  to view this content.
    With this version, whenever you want to email a specific worksheet, first display that sheet ... then press the "m" key (lower case). The userform will show, display the activesheet you are viewing. Click the EMAIL button and voila !
    Close the form when you are finished.

    This method will allow you to move to any sheet in the workbook and not have to place a command button on each sheet (very inconvenient).

    Project attached for review.
    Attached Files Attached Files

  11. #11
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: VBA to send email with outlook

    .
    Hello keibri :

    If you want to send the email regardless of where you are in the workbook ...

    Paste this in the ThisWorkbook module :

    Please Login or Register  to view this content.
    Paste this into a Routine Module :

    Please Login or Register  to view this content.
    When you want to send the email, press the " m " key.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Send email from shared Outlook email address
    By rousseauassociates in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2016, 07:33 AM
  2. Send an email via outlook from and address other than your default email.
    By sungen99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-28-2015, 06:15 PM
  3. Email Macro o send Outlook Email
    By asivaprakash in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2013, 07:05 PM
  4. send selected range in email with default outlook email signature included
    By mdsickler in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-04-2013, 10:50 PM
  5. Send email via outlook
    By sakmsb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-29-2013, 11:14 PM
  6. Send email without using outlook
    By waspandbee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2010, 08:48 AM
  7. VBA to Send Outlook Email
    By Larry.LeBlanc@O in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2009, 02:22 PM

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