Results 1 to 9 of 9

Send Multiple Mail with Excel VBA

Threaded View

RodPosadas Send Multiple Mail with Excel... 12-22-2023, 05:30 AM
ByteMarks Re: Send Multiple Mail with... 12-22-2023, 06:29 AM
RodPosadas Re: Send Multiple Mail with... 12-22-2023, 08:16 AM
mcsythera Re: Send Multiple Mail with... 12-22-2023, 08:35 AM
ByteMarks Re: Send Multiple Mail with... 12-22-2023, 08:28 AM
mcsythera Re: Send Multiple Mail with... 12-22-2023, 08:28 AM
RodPosadas Re: Send Multiple Mail with... 12-22-2023, 08:30 AM
ByteMarks Re: Send Multiple Mail with... 12-22-2023, 08:33 AM
RodPosadas Re: Send Multiple Mail with... 12-22-2023, 08:41 AM
  1. #1
    Registered User
    Join Date
    10-20-2023
    Location
    Dubai
    MS-Off Ver
    365
    Posts
    5

    Thumbs up Send Multiple Mail with Excel VBA

    Thank you to all who proactively supported in getting this error answered.


    ORIGINAL SCRIPT

    Option Explicit

    Sub SendMultipleEMails()

    Dim emailApplication As Object
    Dim emailItem As Object
    Dim lastRow As Long
    Dim rng As Range
    Dim cell As Range


    '''Set the RANGE to run'''
    lastRow = Cells(Rows.Count, "A").End(xlUp).Row
    Set rng = Range("A1:F" & lastRow)


    ''' THE EMAIL TO OUTLOOK '''
    Set emailApplication = CreateObject("Outlook.Application")
    Set emailItem = emailApplication.CreateItem(0)

    With emailItem

    .To = Cells(i, 1).Value
    .CC = Cells(i, 2).Value
    .Subject = Cells(i, 3).Value
    .Body = Cells(i, 4).Value
    ''.Attachments.Add Cells(i, 5).Value

    .Display

    End With

    On Error GoTo 0

    Set emailItem = Nothing
    Set emailApplication = Nothing


    End Sub




    SOLVED SCRIPT (after consolidating the answers)

    Sub SendMultipleEMails()

    Dim emailApplication As Object
    Dim emailItem As Object
    Dim lastRow As Long
    Dim i As Integer

    lastRow = Cells(Rows.Count, "A").End(xlUp).Row

    Set emailApplication = CreateObject("Outlook.Application")

    For i = 2 To lastRow
    Set emailItem = emailApplication.CreateItem(0)

    With emailItem

    .To = Cells(i, 1).Value
    .CC = Cells(i, 2).Value
    .Subject = Cells(i, 3).Value
    .Body = Cells(i, 4).Value

    ''' ADDING ATTACHMENT '''
    If Cells(i, 5).Text <> "" Then
    .Attachments.Add Cells(i, 5).Text
    End If

    If Cells(i, 6).Text <> "" Then
    .Attachments.Add Cells(i, 6).Text
    End If

    If Cells(i, 7).Text <> "" Then
    .Attachments.Add Cells(i, 7).Text
    End If

    .Display

    End With

    On Error GoTo 0

    Set emailItem = Nothing
    Next i
    Set emailApplication = Nothing


    End Sub
    Last edited by RodPosadas; 12-22-2023 at 08:47 AM. Reason: solved

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel can send mail with multiple cells info as email body and subject, befr 3 day of due
    By ExcelUser2707 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-19-2013, 06:49 AM
  2. [SOLVED] Excel can send mail with multiple cells info as email body and subject, befr 3 day of due
    By ExcelUser2707 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-13-2013, 04:29 AM
  3. Help on Excel Macro/VBA Function to assign code to send outlook mail to multiple Receipt's
    By breadwinner in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2013, 06:28 AM
  4. Replies: 0
    Last Post: 04-24-2013, 12:49 PM
  5. Automatic send email (without even click send in mail software) with excel vba ??
    By alexnkc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-17-2013, 08:31 PM
  6. How to e-mail selected row and use e-mail address in a cell to send e-mail from excel
    By syedalamgir in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2010, 02:15 AM
  7. send mail from excel 2000 with multiple attachments
    By ...Patrick in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-20-2006, 07:15 AM

Tags for this Thread

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