The macros works perfectly if all the cells have mail, but if a cell doesn't have mail the macros send me an error, how can I fixed that if the cell doesn't have mail skip it and follow to the next row and so on ...
[Sub EnviarEmail()
'
' Declaramos variables
'
Dim OutlookApp As Outlook.Application
Dim MItem As Outlook.MailItem
Dim celltxt As String
Dim Asunto As String
Dim Correotxt As String
Dim Destinatario As String
Dim Actividad As String
Dim Msg As String
'
Set OutlookApp = New Outlook.Application
'
'Recorremos la columna EMAIL
'
For Each cell In Range("O9:O99")
'
'Asignamos valor a las variables
'
Asunto = "Actividad Pendiente"
Destinatario = cell.Offset(0, -1).Value
Correo = cell.Value
CAPA = cell.Offset(0, -13).Value
Actividad = cell.Offset(0, -2).Value
FechaVencimiento = Format(cell.Offset(0, 1).Value, "dd-mmm-yy")
'
'Cuerpo del mensaje
'
Msg = "Apreciable: " & Destinatario & vbNewLine & vbNewLine
Msg = Msg & "Queremos informarle que tiene una actividad pendiente en la CAPA "
Msg = Msg & CAPA & "." & vbNewLine & vbNewLine
Msg = Msg & "La actividad a realizar es: "
Msg = Msg & Actividad & vbNewLine & vbNewLine
Msg = Msg & "Con fecha compromiso: "
Msg = Msg & FechaVencimiento & "." & vbNewLine & vbNewLine
Msg = Msg & "Le pedimos realizar la actividad a la brevedad posible para evitar que esta se venza y caer en incumplimiento " & vbNewLine & vbNewLine
Msg = Msg & "Atentamente:" & vbNewLine
Msg = Msg & "Ingenierķa de Calidad"
'
Set MItem = OutlookApp.CreateItem(olMailItem)
With MItem
.To = Correo
.Subject = Asunto
.Body = Msg
.Send
'
End With
'
Next
'
End Sub]
Bookmarks