Multiple attachments to send in outlook at one shot
Results 1 to 3 of 3

Thread: Multiple attachments to send in outlook at one shot
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Mar 2019
    Location
    India
    Posts
    185
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Multiple attachments to send in outlook at one shot

    Hi everyone,

    Here i am trying to send multiple attachments at one shot but as i compiled and check its exiting at the point of attachment at the send time
    Any one suggest me with what changes i should do????
    Here is my code
    Code:
    Sub Mail()
    Dim myApp As Outlook.Application, mymail As Outlook.MailItem
    Dim path, signature, emp_name, subject, body As String
    Dim file As String
    Dim x As Long
    On Error GoTo ExitSub
    lastrow = Sheets("Mail").Cells(Rows.Count, "A").End(xlUp).Row
    For x = 2 To lastrow
            path = Cells(x, "A").Value & "\" & Cells(x, "B").Value
            emp_name = Cells(x, "C").Value
            subject = Cells(x, "D").Value
            body = Cells(x, "E").Value
            signature = Cells(x, "G").Value
            Set myApp = New Outlook.Application
            Set mymail = myApp.CreateItem(olMailItem)
            mymail.To = Cells(x, "F").Value
        If path <> "" Then
            If (Cells(x, "D").Value) <> "" Then
                With mymail
                    .subject = subject
                    .Attachments.Add (path)
                    .body = "Hi " & emp_name & "," & vbCrLf & body & vbCrLf & vbNewLine & "Regards," & vbCrLf & signature
                    .Display
                    .send
                End With
            Else
                MsgBox ("Please Enter Mail ID")
                Exit Sub
            End If
        Else
            MsgBox ("Please Path and File Name")
        End If
    Next
    Set myApp = Nothing
    Set mymail = Nothing
    ExitSub:
    End Sub
    Thanks in advance
    Dhruva

  2. #2
    Board Regular
    Join Date
    Mar 2019
    Location
    India
    Posts
    185
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Multiple attachments to send in outlook at one shot

    Hi Everyone,
    If i run the above code it should send the mails to all the recipients with the specific attachments, but as of now it is sending only one mail and gets exited at the 2nd time run.
    Can anyone suggest me what changes i need to make ??????????

    It gets exited at the highlighted row

    Quote Originally Posted by GirishDhruva View Post
    Hi everyone,

    Here i am trying to send multiple attachments at one shot but as i compiled and check its exiting at the point of attachment at the send time
    Any one suggest me with what changes i should do????
    Here is my code
    Code:
    Sub Mail()
    Dim myApp As Outlook.Application, mymail As Outlook.MailItem
    Dim path, signature, emp_name, subject, body As String
    Dim file As String
    Dim x As Long
    On Error GoTo ExitSub
    lastrow = Sheets("Mail").Cells(Rows.Count, "A").End(xlUp).Row
    For x = 2 To lastrow
            path = Cells(x, "A").Value & "\" & Cells(x, "B").Value
            emp_name = Cells(x, "C").Value
            subject = Cells(x, "D").Value
            body = Cells(x, "E").Value
            signature = Cells(x, "G").Value
            Set myApp = New Outlook.Application
            Set mymail = myApp.CreateItem(olMailItem)
            mymail.To = Cells(x, "F").Value
        If path <> "" Then
            If (Cells(x, "D").Value) <> "" Then
                With mymail
                    .subject = subject
                    .Attachments.Add (path)
                    .body = "Hi " & emp_name & "," & vbCrLf & body & vbCrLf & vbNewLine & "Regards," & vbCrLf & signature
                    .Display
                    .send
                End With
            Else
                MsgBox ("Please Enter Mail ID")
                Exit Sub
            End If
        Else
            MsgBox ("Please Path and File Name")
        End If
    Next
    Set myApp = Nothing
    Set mymail = Nothing
    ExitSub:
    End Sub
    Thanks in advance
    Dhruva
    Last edited by GirishDhruva; May 24th, 2019 at 08:09 AM.

  3. #3
    Board Regular
    Join Date
    Mar 2019
    Location
    India
    Posts
    185
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Multiple attachments to send in outlook at one shot

    Hi everyone,

    I have a question that can we send mails from different Mail Id's with having user name and passwords in an excel sheet.

    Regards,
    Dhruva

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •