Notifications
Clear all

Macro para anexar arquivo específico em e-mail

2 Posts
1 Usuários
0 Reactions
910 Visualizações
(@edlemos)
Posts: 8
Active Member
Topic starter
 

Boa tarde,

Utilizo uma macro que envia e-mails com o corpo de texto preenchido a partir de algumas células do excel:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim OutApp As Object
    Dim OutMail As Object
    Dim texto As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    linha = ActiveCell.Row - 1
    If Target.Address = "$F$" & linha Then

        If Plan5.Cells(linha, 6) = "Sim" Then
            texto = "Requisição Nº:  " & Plan5.Cells(linha, 2) & "," & vbCrLf & _
                    "Pedido Nº:  " & Plan5.Cells(linha, 3) & vbCrLf & _
                    "Solicitante:  " & Plan5.Cells(linha, 5) & vbCrLf & _
                    "Observação:  " & Plan5.Cells(linha, 13)
                    
        End If

        With OutMail
            .To = Plan5.Cells(linha, 15)
            .CC = ""
            .BCC = ""
            .Subject = "Requisição Nº: " & Plan5.Cells(linha, 2) & " Data de Faturamento em: " & Plan5.Cells(linha, 4) & ""
            .Body = texto
            .Display   'Utilize Send para enviar o email sem abrir o Outlook
        End With
        On Error GoTo 0

        Set OutMail = Nothing
        Set OutApp = Nothing
    End If
End Sub

Porém, agora preciso anexar alguns arquivos para enviar junto ao e-mail.....O padrão da localização do arquivo é esse:

\servidorpublicoExpediçãoMinutas"célulaB".JPG

 
Postado : 28/04/2015 1:03 pm
(@edlemos)
Posts: 8
Active Member
Topic starter
 

Consegui, adicionei na macro:

.Attachments.Add ("\servidorpublicoExpediçãoMinutas" & Plan5.Cells(linha, 2) & ".jpg")

 
Postado : 28/04/2015 1:21 pm