Results 1 to 7 of 7

Runtime Error 287 - Auto e-mail with attachment problem

Threaded View

  1. #1
    Registered User
    Join Date
    09-12-2018
    Location
    Brasil
    MS-Off Ver
    Office 2013/2018
    Posts
    3

    Thumbs down Runtime Error 287 - Auto e-mail with attachment problem

    Hey guys, what's up?

    I'm with a little problem... I need to send a e-mail with different attachments to a huge list, so I decided to use a VBA program to make it easier. I'm using a code that I found in youtube (source: youtube.com/watch?v=0k8t2Fy6nSc), but it's giving me an error when finalizing the sending. I searched in the forum, but I didn't find anything that could help me to solve my error, so I'm here asking you for some help.

    Here the code, and its error:

    Sub Send_email_fromexcel()
    Dim adress As String
    Dim subj As String
    Dim message As String
    Dim filename As String
    Dim outlookapp As Object
    Dim outlookmailitem As Object
    Dim myAttachments As Object
    Dim path As String
    Dim lastrow As Integer
    Dim attachment As String
    Dim x As Integer
    
    
    
    
     x = 2
    
    Do While Sheet1.Cells(x, 1) <> ""
       
        Set outlookapp = CreateObject("Outlook.Application")
        Set outlookmailitem = outlookapp.createitem(0)
        Set myAttachments = outlookmailitem.Attachments
        path = "C:\Users\Matheus.Marinello\Azul\"
        adress = Sheet1.Cells(x, 1)
          
        subj = Sheet1.Cells(x, 2)
        filename = Sheet1.Cells(x, 3)
        attachment = path + filename
    
    
        
            outlookmailitem.To = adress
            outlookmailitem.cc = ""
            outlookmailitem.bcc = ""
            outlookmailitem.Subject = subj
            outlookmailitem.body = "Please find your statement attached" & vbCrLf & "Best Regards"
               
                
            myAttachments.Add (attachment)
            outlookmailitem.display
            outlookmailitem.send '(error in this line)
                
            lastrow = lastrow + 1
            adress = ""
        x = x + 1
    
    Loop
    
    Set outlookapp = Nothing
    Set outlookmailitem = Nothing
    
    End Sub
    Thank you!
    Last edited by mcmarinello; 09-12-2018 at 01:46 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Error - auto mail extracting mail address from cells
    By Mahesh Rana in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2018, 06:37 AM
  2. Error - auto mail extracting mail address from cells
    By Mahesh Rana in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2018, 02:52 PM
  3. Download Outlook mail to excel - runtime error, array index out of bounds
    By Jarryd12 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2017, 05:04 PM
  4. Problem with adding attachment to e-mail
    By ztiwef in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-04-2013, 12:12 PM
  5. [SOLVED] Auto send mail with attachment
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-13-2013, 09:38 AM
  6. auto save e-mail attachment to folder after sending
    By ncaravela in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-16-2010, 05:23 PM
  7. [SOLVED] Problem in mail attachment when using CDO
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2006, 04:45 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