+ Reply to Thread
Results 1 to 4 of 4

Sending emails with combination of two module

  1. #1
    Forum Contributor
    Join Date
    11-01-2016
    Location
    Prague
    MS-Off Ver
    2013
    Posts
    121

    Sending emails with combination of two module

    Hi Everyone,

    I have an employee list as attached, with manager data in column "V".

    Macro is sending separate emails to each manager with an attachment. For example, a manager have 5 employee. Macro is copying that 5 row and pasting into a blank excel file and attaching that excel file to an email and sending it to the manager.

    Until here, I am able to do it with below code. It is working.

    But now I have a "Sheet2" which I want to do same thing. Filter the manager's employees in Sheet2 and create a second excel file and attach it into that email as well with previous attachment. Basically It will be one email with two excel attachment. Macro needs to match with managers and excel files.

    I did the same code to Sheet2 as well but I dont know how to combine these two macro and send one email with two attachment ://

    Any idea ?


    Thanks a lot !
    Orhan


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by orhanceliloglu; 04-17-2018 at 07:30 AM.

  2. #2
    Registered User
    Join Date
    03-12-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    36

    Re: Sending emails with combination of two module

    Orhan,

    The thing here is is that both codes are calling the command to generate an e-mail.

    What i think you want to do is separate the e-mail part from your code, and make this a singe sub that creates the e-mail and adds both temp files to the email. After you do this just make a Run macro that calls the procedures you need. I would advice to collect the macro's in a singe module as that makes it easier to call them.

    I hope this guides you.

    Kind regards,

    Rekragisao

  3. #3
    Forum Contributor
    Join Date
    11-01-2016
    Location
    Prague
    MS-Off Ver
    2013
    Posts
    121

    Re: Sending emails with combination of two module

    Quote Originally Posted by Rekragisao View Post
    Orhan,

    The thing here is is that both codes are calling the command to generate an e-mail.

    What i think you want to do is separate the e-mail part from your code, and make this a singe sub that creates the e-mail and adds both temp files to the email. After you do this just make a Run macro that calls the procedures you need. I would advice to collect the macro's in a singe module as that makes it easier to call them.

    I hope this guides you.

    Kind regards,

    Rekragisao
    Thank you Rekragisao for your reply. I just find this code somewhere else :/ So, I am not good at these things unfortunately. I tried to add second code just before the End Sub code in 1st module, but It didnt work. It is creating first files but not moving to second. May I kindly ask to guide me a little bit more how to add both temp files into one email ?

    Thanks a lot!
    Orhan
    Last edited by orhanceliloglu; 04-19-2018 at 09:22 AM.

  4. #4
    Registered User
    Join Date
    03-12-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    36

    Re: Sending emails with combination of two module

    Quote Originally Posted by orhanceliloglu View Post
    Thank you Rekragisao for your reply. I just find this code somewhere else :/ So, I am not good at these things unfortunately. I tried to add second code just before the End Sub code in 1st module, but It didnt work. It is creating first files but not moving to second. May I kindly ask to guide me a little bit more how to add both temp files into one email ?

    Thanks a lot!
    Orhan
    Orhan,

    For me the code isn't working at all since you've left out the definitions for your variable i, lastrow and lastcolumn. Furthermore the code is cluttered and hard to read and contains a lot of unneeded code. Seeing as it somehow works for you try adding the second code to module one before the part where you call on the email application (leave out the email call from the second code). then debug everything, this will help teach you how to code this stuff. after the code to create both workbooks runs smoothly change the .attachments.add code to include both the files you made.

+ 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. Sending emails
    By mshussain in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-02-2016, 03:14 PM
  2. Sending Emails under conditions!
    By JVerwee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2013, 05:57 AM
  3. [SOLVED] Sending Outlook emails from Excel; Limits to three emails only?
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2013, 06:53 AM
  4. Vba for sending emails
    By shagrath in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-26-2011, 10:28 AM
  5. Sending Emails VBA - Specify Who From
    By BenRoylance in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2010, 06:00 AM
  6. Sending emails
    By Sibrulotte in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-26-2010, 10:31 AM
  7. Sending macro emails using excel: Send emails with their passwords.
    By loveisblind in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2009, 03:16 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