VBA + Outlook

Edson Santos 294

New Member
Joined
Feb 27, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Guys, good morning/afternoon/evening,

I'm having an issue with Excel VBA while automating an email send-out.

My code sends approximately 17/18 emails and then crashes with the following error:

I'm not sure what might be happening, can you help me? I don't think it's Microsoft limiting the sends per time period because I just close the error and click again to run the macro, and it sends another 17/18 normally.

Here's the code for you to take a look at.

Sub enviar_email()

Dim w As Worksheet
Dim nRows As Long

Set objeto_outlook = CreateObject("Outlook.Application")
Set w = Sheets("Templ.")

nRows = w.Cells(w.Rows.Count, 1).End(xlUp).Row


For linha = 7 To nRows

Sheets("Templ.").Select

Set Email = objeto_outlook.createitem(0)
Email.display

Email.To = Cells(linha, 2).Value
'cópia-->Email.cc =
'Cópia oculta --> Email.bcc =

Sheets("Corpo de email").Select

Email.Subject = Cells(2, 1)

Sheets("Templ.").Select

'As duas linhas abaixo são variáveis que serão usadas no email em HTML
texto1 = "Olá, " & Cells(linha, 3) & "," & "<br>"


'A linha abaixo começa o email de fato
Sheets("Corpo de email").Select
Email.htmlbody = texto1 & RangetoHTML(Range("corpo2")) _
& Email.htmlbody
'A linha acima coloca a assinatura no corpo do email

Email.Attachments.Add ("\\ctbn33\_CS\PMD\Acompanhamento Dashboards\myBühler\Enviar e-mail automaticamente\myBühler.pdf")
Email.send

Sheets("Templ.").Select

1709048633699.png



Next


End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Oh, I forgot to send the error screenshot, here it is:

Traduction: Error in execution time '440':
There is no support in the object for this method.

1709048827410.png
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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