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.
#38462
Olá pessoal boa tarde, tudo bem? Estou tentando fazer com que alguns dos e-mails enviados desde uma planilha de excel/outlook, que tenham determinada condicao sejam enviados com alta importancia. Esta condição é conter a palavra celular no Suject do e-mail.

Este é o código que uso para o envio de e-mails:
Código: Selecionar todos
Sub BOTAO_enviar()
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    
    On Error Resume Next
    
    Application.DisplayAlerts = False
    
    With OutMail
    .To = "meuemail@meuemail.com"
    .Subject = Range("g16")
    .HTMLBody = "<b>Resultado 1: </b>" & Range("D3").Value & "<br>" & _
    "<b>Resultado 2: </b>" & Range("D4").Value & "<br>" & _
    "<b>Telefone: </b>" & Range("g17").Value & "<br>"
    .Send
    End With
    
    Application.DisplayAlerts = True

End Sub
Tentei fazer o seguinte e nao funcionou:
Código: Selecionar todos
Sub BOTAO_enviar()
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    
    On Error Resume Next
    
    Application.DisplayAlerts = False
    
    With OutMail
    .To = "meuemail@meuemail.com"
    .Subject = Range("g16")

    If .Subject = "&CELULAR&" Then 

    .Importance = 2

    End If

    .HTMLBody = "<b>Resultado 1: </b>" & Range("D3").Value & "<br>" & _
    "<b>Resultado 2: </b>" & Range("D4").Value & "<br>" & _
    "<b>Telefone: </b>" & Range("g17").Value & "<br>"
    .Send
    End With
    
    Application.DisplayAlerts = True

End Sub
Se eu tiro a condição If e mantenho o .Importance = 2, todos os e-mails sao enviados com alta importancia.

Alguém poderia me ajudar com isso por favor?

Obrigado.
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