+ Reply to Thread
Results 1 to 9 of 9

Macro to create emails, attach files, add recipient and add subject line

  1. #1
    Forum Contributor
    Join Date
    06-26-2014
    Location
    Houston
    MS-Off Ver
    365
    Posts
    196

    Macro to create emails, attach files, add recipient and add subject line

    Good Morning,

    I create some pdf's and spreadsheets and save to a folder, then I have to send them to the same person. There is one pdf and sheet for each email, and they are named the exact same. Is there a way with a macro to create an email with the recipient being the same, attaching both files, and entering the subject line as the name of one of the files, doesn't matter which one since they are both names the same? Furthermore, would it be possible with one step to do this for multiple emails? Essentially I have about 60 files, 2 of each go on one email, so about 30 emails, that go to the same person.

    Thanks!

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Macro to create emails, attach files, add recipient and add subject line

    Is there a way with a macro to create an email
    A very common topic - try searching for some basic code.

  3. #3
    Forum Contributor
    Join Date
    06-26-2014
    Location
    Houston
    MS-Off Ver
    365
    Posts
    196

    Re: Macro to create emails, attach files, add recipient and add subject line

    I have, I'm not much a a VBA expert. I can add a basic create an email. This is a little bit more complex. I have one folder with 60 files, 30 excel, and 30 pdf. One excel corresponds with one pdf, they would have the same name. Example, there is one excel named "4-2017 Best Buy Statement" and one PDF named "4-2017 Best Buy Statement", there is one excel named "4-2017 Radio Shack Statement" and one pdf named "4-2017 Radio Shack Statement", and about 28 other sets. They all have to go to the same person, and each email subject would be titled the way the statement is named. So the first email will be to "same recipient", subject "4-2017 Best Buy Statement" and attach both best buy files, the second email would be "same recipient" , subject line " 4-2017 Radio Shack Statement", with both Radio shack statements, etc. So it would have to go and determine that there are two files with the same name, create one email for those and attach them, then address it to one person and attach both of those files, then send. Any ideas?

    Thanks!

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Macro to create emails, attach files, add recipient and add subject line

    Never mind trying to get everything working to start with - you'll only confuse yourself.

    Go find a thread to create an email (in the absence of any code you may have), for example the 3rd result from this search looks like a good candidate - once you get that working with a couple of attachments then you can concentrate on picking up the correct attachments.

  5. #5
    Forum Contributor
    Join Date
    06-26-2014
    Location
    Houston
    MS-Off Ver
    365
    Posts
    196

    Re: Macro to create emails, attach files, add recipient and add subject line

    Ok, I'll take a look at it. I know its a lot, but I figured there has to be a way, if only one step at a time. Thanks.

  6. #6
    Forum Contributor
    Join Date
    06-26-2014
    Location
    Houston
    MS-Off Ver
    365
    Posts
    196

    Re: Macro to create emails, attach files, add recipient and add subject line

    I've gotten this far, but its in excel, not outlook, not sure if it makes a difference. Successfully opens an email, attaches the file I specify, and sends.



    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Macro to create emails, attach files, add recipient and add subject line

    Assuming you want to run this in Outlook...

    Remove the 'New' keyword from the line
    Please Login or Register  to view this content.
    Not that is really matters as only 1 instance of Outlook can run but if this was in Excel (and referencing 'Excel.Application') it would start a 2nd instance of Excel. Might as well get it right to start with.

    Actually, you can probably remove references to olApp and simply refer to the Application object - as you're running it in Outlook, that's the application
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    06-26-2014
    Location
    Houston
    MS-Off Ver
    365
    Posts
    196

    Re: Macro to create emails, attach files, add recipient and add subject line

    So should I open VBA from Outlook then insert a new module and apply this code?

  9. #9
    Forum Contributor
    Join Date
    06-26-2014
    Location
    Houston
    MS-Off Ver
    365
    Posts
    196

    Re: Macro to create emails, attach files, add recipient and add subject line

    I just added this in a module in VBA in outlook, and it ran successfully.

+ 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. Replies: 1
    Last Post: 08-05-2016, 02:33 PM
  2. Auto-Reply to Emails based on their subject line using VBA
    By e4excel in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 08-11-2015, 10:23 AM
  3. [SOLVED] Loop Through Folder, Create Emails with Sub Folder Names in Subject, Attach files in sub
    By Rschwar23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2015, 10:06 AM
  4. Importing emails and subject line
    By sathishkm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-21-2013, 07:02 AM
  5. VB Code to copy subject line and emails
    By sathishkm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2013, 01:59 PM
  6. Save emails using only part of subject line
    By ir26121973 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-03-2006, 02:45 PM
  7. [SOLVED] Create an e-mail with recipient, subject and text
    By Martin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2005, 08:25 AM

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