+ Reply to Thread
Results 1 to 11 of 11

Creating multiple e-mails with separate attachments

  1. #1
    Registered User
    Join Date
    09-16-2017
    Location
    London
    MS-Off Ver
    Office 2016
    Posts
    24

    Creating multiple e-mails with separate attachments

    Hi All,

    so I have two issues with the code below:

    1. I am attempting to create a macro that e-mail seperate e-mail addresses with separate attachments based on the cells in the homesheet. However, when I run it, I get a 'select method of worksheet failed' error at
    PHP Code: 
    Parent.Select 
    . When I attempt again to run it, it works. I'd prefer it if it worked first time round everytime.

    2. Then when the code runs, it does everything I want except there is a divider in the e-mail body between the 'Intro' and the rest of the body which I'd like to remove.

    Appreciate any advice on this.

    PHP Code: 
    Sub Send_Range_Or_Whole_Worksheet_with_MailEnvelope()

        
    sn Sheets("Contacts").Cells(1).CurrentRegion.Value
        With Application
            
    .ScreenUpdating False
            
    .EnableEvents False
        End With
        
      
            
    For 2 To UBound(sn)
            
    ActiveWorkbook.EnvelopeVisible True
            Set Sendrng 
    Sheets(sn(i1)).Range("A1:M71")
            
    With Sendrng
                
    .Parent.Select
                With 
    .Parent.MailEnvelope
                    
    .Introduction sn(i4)
                    
    With .Item
                        
    .To sn(i2)
                        .
    Subject sn(i3)
                        .
    Attachments.Add sn(i5)
                        .
    Send
                    End With
                End With
            End With
        Next
        ActiveWorkbook
    .EnvelopeVisible False
        With Application
            
    .Goto Sheets("Contacts").Range("A1")
            .
    ScreenUpdating False
            
    .EnableEvents False
        End With
    End Sub 
    Last edited by daryl83; 09-18-2017 at 12:17 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,471

    Re: Creating multiple e-mails with separate attachments

    .
    I've not had much success with the MailEnvelope version of creating an email. If you are interested, here is another macro that pretty much does what you want.
    You can tweek it to your specifications:

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

  3. #3
    Registered User
    Join Date
    09-16-2017
    Location
    London
    MS-Off Ver
    Office 2016
    Posts
    24

    Re: Creating multiple e-mails with separate attachments

    This is much more straightforward. Thanks!

  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,471

    Re: Creating multiple e-mails with separate attachments

    You are welcome

  5. #5
    Registered User
    Join Date
    09-27-2017
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    13

    Re: Creating multiple e-mails with separate attachments

    Hello,

    Thank you both, this code is perfect for me but I would need something more, sorry but I am very new in VBA and I would need to add a column B for the CC as well. Could you please adapt this code for this. It would be great.

    Thanks again.

    Edid: Not needed yet, I have already done it. Thanks
    Last edited by Mercurioneo; 09-28-2017 at 08:59 AM.

  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,471

    Re: Creating multiple e-mails with separate attachments

    .
    See the attached with changes
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    09-27-2017
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    13

    Re: Creating multiple e-mails with separate attachments

    Thanks, I did it in the same way, but I appreciate your help a lot.

  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,471

    Re: Creating multiple e-mails with separate attachments

    .
    Does it work for you ? It works here. Just want to make certain.

  9. #9
    Registered User
    Join Date
    09-27-2017
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    13

    Re: Creating multiple e-mails with separate attachments

    Yes it worked. I cannot attach my file because it seems disabled for me

  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,471

    Re: Creating multiple e-mails with separate attachments

    Great ! Cheers

  11. #11
    Registered User
    Join Date
    09-27-2017
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    13

    Re: Creating multiple e-mails with separate attachments

    Quote Originally Posted by Logit View Post
    Great ! Cheers
    Hello Logit,

    I am attaching the link to my final file, I have create a new code to create L3 files that have to contain some pivot tables in another sheet. I prefer your code it is very fast compared with mine and more optimized, but I wasn't able to create the pivot tables with your code. Could you please adapt my code (Sub L3creation) to work as good as yours (subL4creation)

    Thanks in advance, if it is not possible or you are busy thanks anyway for your time.

    https://www.dropbox.com/s/i80pve8eha...test.xlsm?dl=0
    Last edited by Mercurioneo; 10-11-2017 at 05:24 AM.

+ 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. [SOLVED] Create E-mails in a G-Mail account with attachments using VBA
    By spiwere in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-26-2017, 02:54 PM
  2. Send mails with attachments using a macro
    By Warmerfare in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 03-27-2017, 08:13 AM
  3. Excel containing macro to send bulk mails from outlook with multiple attachments
    By amandeep08 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2013, 02:19 PM
  4. Extract XLS* attachments from select mails, save mail info into fields
    By Alteregoist in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-14-2013, 05:35 AM
  5. Problem using a macro to send multiple emails with separate attachments
    By joshthorntonwhite in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-29-2013, 07:31 AM
  6. Attachments when sending mails with excel
    By Steffen Thomsen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2011, 05:27 AM
  7. Using VBA to create mails with multiple attachments (Syntax Query)
    By Big Chris in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2007, 07:41 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