Excel VBA - EMAIL usando GMAIL
Bom dia pessoal!
Preciso enviar uma imagem no corpo do e-mail, no momento estou usando o código abaixo, como faço para incluir uma imagem ao final do texto?
Tentei incluir o código abaixo mas não deu certo... Envia o e-mail normalmente mas sem a imagem.
.HTMLBody = Email_Body & "<html><body><img src=""G:\SETOR DE CADASTRO\WELLINGTON\SIGN.jpg""></body></html>"
Private Sub btnEmail_Click()
Dim myMail As CDO.Message
Set myMail = New CDO.Message
Dim Login_EmailAddress, Login_EmailPassword, SMTPServer As String
Dim ServerPort, x, linha As Integer
Dim To_Email, CC_Email, BCC_Email, Email_Subject, Email_Body, Attachment_Path As String
Dim FileExtn As String
FileExtn = ".PDF"
SMTPServer = "smtp.gmail.com"
ServerPort = 465
Login_EmailAddress = Sheet1.Range("O2").Value
Login_EmailPassword = Sheet1.Range("O3").Value
With myMail.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = ServerPort
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = Login_EmailAddress
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Login_EmailPassword
.Update
End With
Range("A1").Select
linha = Range("A999").End(xlUp).Row
For x = 2 To linha
To_Email = Cells(x, 1).Value
CC_Email = Cells(x, 2).Value
'BCC_Email = Sheet1.Range("L4").Value
Attachment_Path = Cells(x, 7).Value
Email_Subject = Cells(x, 8).Value
Email_Body = Cells(x, 9).Value
If Sheet1.Range("G2").Value <> "" Then
Sheet1.Calculate 'to refresh sheet
Attachment_Path = VBA.UCase(Sheet1.Range("G2").Value)
If VBA.InStr(Attachment_Path, FileExtn) > 0 Then Attachment_Path = VBA.Replace(Attachment_Path, FileExtn, "")
End If
With myMail
.From = Login_EmailAddress
.Subject = Email_Subject
.To = To_Email
.CC = CC_Email
.BCC = BCC_Email
.HTMLBody = Email_Body & "<html><body><img src=""G:\SETOR DE CADASTRO\WELLINGTON\SIGN.jpg""></body></html>"
If Attachment_Path <> "" Then .AddAttachment Attachment_Path & FileExtn
End With
On Error Resume Next
myMail.Send
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical
Else
Cells(x, 1).Interior.Color = vbYellow
End If
Next x
Set myMail = Nothing
End Sub
Pronto! Vi em uma outra pergunta daqui algo similar e obtive uma resposta, porém... Gerou outra dúvida. A solução é no lugar do caminho da imagem, inserir um link de uma imagem da web. Dessa forma dá certo, porém o que eu quero enviar não posso publicar assim na web, gostaria que fosse tirado do meu drive compartilhado, tentei e não consegui, mesmo alterando as configurações de privacidade para qualquer usuário da WEB.