Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
Por hgt
#7100
Prezados,

Estou com dificuldades em inserir minha assinatura do outlook via VBA, tentei várias macros mas nenhuma funcionou.

Abaixo a macro que estou usando:

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 = "$H$" & linha Then

If Plan1.Cells(linha, 8) = "Concluído" Then
texto = "Prezado(a) " & Plan1.Cells(linha, 4) & "," & vbCrLf & vbCrLf & _
"a) Sua amostra está disponível para retirada aqui no LRAC; por favor, informe o número de seu pedido (" & Plan1.Cells(linha, 1) & ") para retirada da amostra." & vbCrLf & vbCrLf & _
"b) Segue link com o mapa para localização do laboratório." & vbCrLf & _
"http://www.feq.unicamp.br/index.php/lra ... hegar-lrac" & vbCrLf & vbCrLf & _
"Atenciosamente,"
End If

With OutMail
.To = Plan1.Cells(linha, 7)
.CC = ""
.BCC = ""
.Subject = "Título do email"
.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

------------

Vejam que não tem nenhuma informação de assinatura, pois tentei de tudo, aguardo a ajuda de alguém.

Muito obrigado pessoal
Por hgt
#7111
Oi Alexandre, muito obrigado pela ajuda.

Ficou ótimo, porém não estou conseguindo fundir as duas macros, se utilizo a macro da assinatura só ela quem aparece, tem como eu fazer esta fusão para enviar e-mail quando eu mudar uma condição de uma célula específica?

Obrigado
#7112
Bom dia!!

Mostre a outra macro.

O meu problema é que eu não consigo testar pois eu não uso outlook do pacote (standar2010).

Att
Por hgt
#7114
Oi Alexandre, veja o que estou fazendo
Código: Selecionar todos
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 = "$H$" & linha Then

        If Plan1.Cells(linha, 8) = "Concluído" Then
            texto = "Prezado(a) " & Plan1.Cells(linha, 4) & "," & vbCrLf & vbCrLf & _
                    "a) Sua amostra está disponível para retirada aqui no LRAC; por favor, informe o número de seu pedido (" & Plan1.Cells(linha, 1) & ") para retirada da amostra." & vbCrLf & vbCrLf & _
                    "b) Segue link com o mapa para localização do laboratório." & vbCrLf & _
                    "http://www.feq.unicamp.br/index.php/lrac2/como-chegar-lrac" & vbCrLf & vbCrLf & _
                    "Atenciosamente,"
        End If

        With OutMail
            .To = Plan1.Cells(linha, 7)
            .CC = ""
            .BCC = ""
            .Subject = "Título do email"
            .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
Código: Selecionar todos
Sub Mail_Outlook_With_Signature_Html_1()
' Working in Office 2000-2016
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String

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

    strbody = "<H3><B>Prezado(a)</B></H3>" & "," & _
              "Please visit this website to download the new version.<br>" & _
              "Let me know if you have problems.<br>" & _
              "<A HREF=""http://www.rondebruin.nl/tips.htm"">Ron's Excel Page</A>" & _
              "<br><br><B>Thank you</B>"

    On Error Resume Next

    With OutMail
        .Display
        .To = "Plan1.Cells(linha, 7)"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .HTMLBody = strbody & "<br>" & .HTMLBody
        .Display
    End With

    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
Código: Selecionar todos
Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
    Dim fso As Object
    Dim ts As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
    GetBoiler = ts.readall
    ts.Close
End Function
#23797
Boa tarde!!

Você quer fazer o quê com a rotina que está dentro da sua guia, adicionar a assinatura ?

Seria isso?
Código: Selecionar todos
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OutApp As Object
Dim OutMail As Object
Dim texto As String
Dim strbody As String 'Adicionar assinatura

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

'Adicionar assinatura
strbody = "<H3><B>Prezado(a)</B></H3>" & "," & _
"Please visit this website to download the new version.<br>" & _
"Let me know if you have problems.<br>" & _
"<A HREF=""http://www.rondebruin.nl/tips.htm"">Ron's Excel Page</A>" & _
"<br><br><B>Thank you</B>"


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

If Plan1.Cells(linha, 8) = "Concluído" Then
texto = "Prezado(a) " & Plan1.Cells(linha, 4) & "," & vbCrLf & vbCrLf & _
"a) Sua amostra está disponível para retirada aqui no LRAC; por favor, informe o número de seu pedido (" & Plan1.Cells(linha, 1) & ") para retirada da amostra." & vbCrLf & vbCrLf & _
"b) Segue link com o mapa para localização do laboratório." & vbCrLf & _
"http://www.feq.unicamp.br/index.php/lrac2/como-chegar-lrac" & vbCrLf & vbCrLf & _
"Atenciosamente,"
End If

With OutMail
    .To = Plan1.Cells(linha, 7)
    .CC = ""
    .BCC = ""
    .Subject = "Título do email"
    .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

att
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord