Results 1 to 17 of 17

Macro to send mails from outlook as per the email ids in excel

Threaded View

  1. #5
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: Macro to send mails from outlook as per the email ids in excel

    Quote Originally Posted by john55 View Post
    maybe
    Sub Button1_Click()
       Dim ce As Range, i As Long
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strto As String, strcc As String, strbcc As String
        Dim strsub As String, strbody As String
    
     c01 = "c:\users\mark\desktop\dgr.txt" 'change the path and the file name
        For i = 2 To Sheets("Sheet1").Range("a65536").End(xlUp).Row
            If Cells(i, 1).Value <> "" Then
                Set OutApp = CreateObject("Outlook.Application")
                OutApp.Session.Logon
                Set OutMail = OutApp.CreateItem(0)
            
                With Sheets("Sheet1")
                    strto = .Cells(i, 4).Value 'column d
                    strcc = .Cells(i, 5).Value
                    strbcc = ""
                    strsub = "Welcome to the Project " & " " & .Cells(i, 2)
                    strbody = "Hi there," & vbCrLf & "We welcome you all to the project" & " " & .Cells(i, 2).Value & " " & _
                        "whatever...." & _
                        vbCrLf & vbCrLf & "Thank you."
                End With
        
                With OutMail
                    .To = strto
                    .CC = strcc
                    .BCC = strbcc
                    .Subject = strsub
                    .Body = strbody
                    .attachments.Add c01
                    '.Send
                    .display
                    Cells(i, 1).Select
         With Selection.Font
            .Color = -16776961
            .TintAndShade = 0
        End With
                End With
        
                Set OutMail = Nothing
                Set OutApp = Nothing
            End If
      
        Next i
    End Sub
    Thanks a lot for your reply.. I appreciate the way you explained the codes..

    I an getting the error that says "Run-time error 440: Automation error "..

    Please help.. Attaching the file with codes..
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. convert excel sheet to pdf using macro and send that pdf via email using outlook
    By suresh mongam in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-25-2015, 08:51 AM
  2. [SOLVED] Macro to send email from excel using outlook
    By Teblol in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 02-10-2015, 06:47 PM
  3. Macro to send notification from excel to my Outlook Email
    By savethisid in forum Excel General
    Replies: 18
    Last Post: 03-27-2014, 02:25 PM
  4. 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
  5. Replies: 2
    Last Post: 01-06-2010, 06:12 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