Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Ayuda con macro para enviar mensajes

publicado

Hola,

A partir de dos macros que encontré en el foro (disculpen no recuerdo a los autores) hice esta macro, pero me da un error de automatización.

Alguien que sepa VB me ayude porque apenas si entiendo esto.

La macro es para enviar correos a travez de outlook, la lista de correos y los nombre de los destinatarios están en dos columnas en excel.

Sub EnviaCorreo()
Dim myOLApp
Dim myOLItem
Dim olMailItem
Dim midire, minombre, miasunto As String
Dim Firma As String
Dim ts As Object
Dim fso As Object


'se establece la ruta de la firma
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile("C:\Users\Sergio\AppData\Roaming\Microsoft\Firmas\Sergio.htm").OpenAsTextStream(1, -2)
Firma = ts.readall
ts.Close


'Bucle para envio de varios correos
For i = 1 To 20


'datos del mail a enviar
midire = ActiveSheet.Range("B" & i).Value
minombre = ActiveSheet.Range("C" & i).Value
miasunto = ActiveSheet.Range("D1").Value


'se crea un objeto Outlook, Mail
Set myOLApp = CreateObject("Outlook.Application")


Set myOLItem = myOLApp.CreateItem(olMailItem)


'se establecen los campos del mensaje
With myOLItem
'campo A o Para
.To = midire
'campo Asunto
.Subject = miasunto
.BodyFormat = 2 'olFormatHTML
'cuerpo del mensaje
.HTMLBody = "<HTML> " & _
"<BODY>" & _
"<P>" & "Buenas tardes" & " " & minombre & "," & _
"</P> " & "Molesto tu atención ......" & _
"<P>" & _
"<P>" & "Hasta luego," & _
"<P>" & _
"<P>" & Firma & _
"</BODY> " & _
"</HTML>"


'enviar
.Send
End With


Next


'se liberan las variables creadas
Set myOLApp = Nothing
Set myOLItem = Nothing


End Sub[/CODE]

Gracias por la ayuda

Featured Replies

publicado

El código lo veo bien, ya me pasó antes ese error, No olvides que debes crear una referencia a la biblioteca de MS Outlook desde Herramientas>Referencias>MS Outlook X Objet Library

Saludos desde Colombia

publicado
  • Autor

Gracias por la respuesta.

Hice lo que me dijiste pero me sale este error al ejecutar la macro.

[ATTACH]37927.vB[/ATTACH]

post-136738-145877007234_thumb.jpg

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.