Sending e-mail, multiple attachment, different names VBA

gallzsoltv

New Member
Joined
Feb 7, 2019
Messages
2
Hello!

A have a working macro (sending email), but I want to upgrade it.



Here is the excel sheet "Munka1":

.to.cc.body.attachments
smith@gmail.comcc@cc.com; [email]bb@bb.com[/EMAIL]HI ALLC:\Users\gall\Desktop\Test\Smith Jackson_tomorrow_201812.xlsx
joe@gmail.comcc@cc.com; [email]bb@bb.com[/EMAIL]HI ALLC:\Users\gall\Desktop\Test\Joe Simon data_sending_201812.xlsx
neo@gmail.comcc@cc.com; [email]bb@bb.com[/EMAIL]HI ALLC:\Users\gall\Desktop\Test\Neo James_data sending_201812.xlsx
neo@gmail.comcc@cc.com; [email]bb@bb.com[/EMAIL]HI ALLC:\Users\gall\Desktop\Test\Neo James_analize test_201812.xlsx
anna@gmail.comcc@cc.com; [email]bb@bb.com[/EMAIL]HI ALLC:\Users\gall\Desktop\Test\Anna Smith_today_201812.xlsx

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>

Here is the macro:
Code:
Sub Sending_Mail()


Dim OutApp As Object
Dim OutMail As Object
Dim sh As Worksheet
Dim cell As Range
Dim FileCell As Range
Dim rng As Range






With Application
    .EnableEvents = False
    .ScreenUpdating = False
End With


Set sh = Sheets("Munka1")




Set OutApp = CreateObject("Outlook.Application")


For Each cell In sh.Columns("A").Cells.SpecialCells(xlCellTypeConstants)




    Set rng = sh.Cells(cell.Row, 1).Range("D1:Z1")
    
    If cell.Value Like "?*@?*.?*" And _
    Application.WorksheetFunction.CountA(rng) > 0 Then
        Set OutMail = OutApp.CreateItem(0)
        
        With OutMail
            .to = sh.Cells(cell.Row, 1).Value
            .CC = sh.Cells(cell.Row, 2).Value
            .Subject = "HI all!!"         '<<<
           
            
            For Each FileCell In rng.SpecialCells(xlCellTypeConstants)
                If Trim(FileCell.Value) <> "" Then
                    If Dir(FileCell.Value) <> "" Then
                        .Attachments.Add FileCell.Value
                                                                      
                    End If
                End If
                
            .Display
            Next FileCell
                                   
        End With
        
        Set OutMail = Nothing
    End If
Next cell


Set OutApp = Nothing


With Application
    .EnableEvents = True
    .ScreenUpdating = True
End With






End Sub


How it is possible to send multiple attachment by ONE email?
For exemple do not send for Neo two emails with one-one attachment, send just ONE, with two attachment. I think I need DO - while command... Can you help me out?

Thanks for the answers!
 
Last edited by a moderator:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Please update on the same.. what will code for send multiple attachments in one mail with path given in two or more column
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,840
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top