Adjuntar archivo a correo desde excel

Me apoyaste con una macro para mandar un rango de una hoja de Excel. EXCELENTE y la he usado por meses.

¿Me apoyas con un código para adjuntar un archivo?

1 Respuesta

Respuesta
1

Te marco en negrita la línea que se usa para adjuntar archivos, deberás incluirla en tu macro antes del .Send (también puede ser .Preview). En este caso pone la ruta completa, pero también puedes poner una variable.

Sub EmailViaOutlook()

    Dim oEmail As New clsOutlookEmail

    With oEmail

        .AddToRecipient = "[email protected]"

        .Subject = "The file you requested"

         .Body = "Here is the file you requested."

        .AttachFile = "C:\My Documents\Report.xls"

        .Send

    End With

    Set oEmail = Nothing

End Sub

Me muestra error

Esta es mu Macro

Sub Send_Range()
    ' Por Jorge Cue Perez
    Row = ActiveCell.Row
    Customer = Row
    custname = Range("O" & Customer & "")
    Cmail = Range("N" & Customer)
    CCmail = Range("O8")
    Fromm = Range("N10")
    Destinn = Range("P10") & " " & Range("P11") & " " & Range("P12") & " " & Range("P13") & " " & Range("P14")
    Range("P17") = custname & ","
    ActiveSheet.Range("P17").CurrentRegion.Select
    ActiveWorkbook.EnvelopeVisible = True
    With Selection.Parent.MailEnvelope
        .Introduction = ""
        .Item.to = " " & Cmail & " "
        .Item.CC = " " & CCmail & " "
        .Item.Subject = "Ffreight rate needed " & Destinn
    '    .AttachFile = "C:\Users\gperez\DESTINATIONS JANUARY 2016.xls"
        .Item.Send
    End With
    Range("P" & Customer).Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorLight2
        .TintAndShade = 0.799981688894314
        .PatternTintAndShade = 0
    End With

No funciona el adjuntar
   

End Sub

No sabia que usabas MailEnvelope, en ese caso:

.Item.Attachments.Add "C:\Users\gperez\DESTINATIONS JANUARY 2016.xls"

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas