Página 1 de 1

Definir prioridade alta email outlook

Enviado: 24 Ago 2016 às 13:40
por CleuberZago
Falai pessoal...

Tenho uma rotina a qual faz o envio de emails de arquivos PDF gerados conforme minha demanda, e gostaria de inserir nele a função de definir a prioridade como sendo alta para envio, vi a função .Importance = olImportanceHigh, onde é possível definir a prioridade como alta, porém não consegui adapta-la a rotina que ja tenho.

Alguém poderia me auxiliar?
Código: Selecionar todos
Option Explicit
Sub Mail_Every_Worksheet_With_Address_In_A1_PDF()
'Working only in 2007 and up
    Dim sh As Worksheet
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim FileName As String
    'Temporary path to save the PDF files
    'You can also use another folder like
    'TempFilePath = "C:\Users\Ron\MyFolder\"
    TempFilePath = Environ$("temp") & "\"
        Plan15.Range("EM76").Value = Now()
            TempFileName = TempFilePath & "ORDEM DE COMPRA Nº " & Plan15.Range("GY4").Value & " - " _
                         & Format(Now, "dd-mm-YYyy hH-mm-ss") & ".pdf"

            FileName = RDB_Create_PDF(Source:=Plan15, _
                                      FixedFilePathName:=TempFileName, _
                                      OverwriteIfFileExist:=True, _
                                      OpenPDFAfterPublish:=False)

            'If publishing is OK create the mail
            If FileName <> "" Then
                RDB_Mail_PDF_Outlook FileNamePDF:=FileName, _
                                     StrTo:=Plan15.Range("FW13").Value, _
                                     StrCC:="", _
                                     StrBCC:="", _
                                     StrSubject:="Solicitação DuPont Pioneer | " & Plan15.Range("P10") & " - " & Format(Now, "dd/mm"), _
                                     Signature:=True, _
                                     Send:=False, _
                                     StrBody:="<BODY style=font-size:11pt;font-family:calibri><b>Caro fornecedor;</b><p>Segue em anexo ordem de compra nº " & Plan15.Range("GY4").Value & ", favor enviar cotação para a mesma e aguardar ordem de envio.</BODY>"
                '.Importance = olImportanceHigh
            Else
                MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
                       "Microsoft Add-in is not installed" & vbNewLine & _
                       "You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
                       "The path to Save the file in arg 2 is not correct" & vbNewLine & _
                       "You didn't want to overwrite the existing PDF if it exist"
            End If
End Sub
Código: Selecionar todos
Function RDB_Mail_PDF_Outlook(FileNamePDF As String, StrTo As String, _
                              StrCC As String, StrBCC As String, StrSubject As String, _
                              Signature As Boolean, Send As Boolean, StrBody As String)
    Dim OutApp As Object
    Dim OutMail As Object
    

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

    On Error Resume Next
    With OutMail
        If Signature = True Then .Display
        .To = StrTo
        .CC = StrCC
        .BCC = StrBCC
        .Subject = StrSubject
        .HTMLBody = StrBody & .HTMLBody
        .Attachments.Add FileNamePDF
        If Send = True Then
            .Send
        Else
            .Display
        End If
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Function

Re: Definir prioridade alta email outlook

Enviado: 25 Ago 2016 às 08:50
por alexandrevba
Bom dia!!

Já tentou a linha:
Código: Selecionar todos
.Importance = olImportanceHigh 
Fonte:
https://msdn.microsoft.com/pt-br/librar ... 66759.aspx

Att

Definir prioridade alta email outlook

Enviado: 25 Ago 2016 às 08:54
por CleuberZago
Bom dia, Alexandre...

Tentei sim cara, até mencionei isso no primeiro post, porém não consegui adapta-la à essa rotina que já tenho.

Re: Definir prioridade alta email outlook

Enviado: 25 Ago 2016 às 09:29
por alexandrevba
Bom dia!!

Como assim não conseguiu adaptar?
Gerou erro? vc não sabe onde incluir o comando?


segundo a rotina do ron de broin, fica dentro do escopo do objeto
Código: Selecionar todos
With OutMail
.

Qual versão está usando?
talvez para versões acima de 2010...
Código: Selecionar todos
.Importance = 2
Outras fontes:
http://www.slipstick.com/developer/crea ... using-vba/
http://qlockwork.com/timetrackingthough ... ew-emails/

Att

Definir prioridade alta email outlook

Enviado: 25 Ago 2016 às 11:41
por CleuberZago
Consegui, Alexandre...

O que acontece é que uso a versão 2010 e na rotina estava usando o argumento olImportanceHigh, que é pra versões posteriores, mudei pra 2 como disse e deu tudo certo.

Tópico resolvido. Pra quem futuramente precisar, segue os códigos.
Código: Selecionar todos
Function RDB_Mail_PDF_Outlook(FileNamePDF As String, StrTo As String, _
                              StrCC As String, StrBCC As String, StrImportance As String, StrSubject As String, _
                              Signature As Boolean, Send As Boolean, StrBody As String)
    Dim OutApp As Object
    Dim OutMail As Object
    

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

    On Error Resume Next
    With OutMail
        If Signature = True Then .Display
        .To = StrTo
        .CC = StrCC
        .BCC = StrBCC
        .Importance = StrImportance
        .Subject = StrSubject
        .HTMLBody = StrBody & .HTMLBody
        .Attachments.Add FileNamePDF
        If Send = True Then
            .Send
        Else
            .Display
        End If
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Function
Código: Selecionar todos
Option Explicit
Sub Mail_Every_Worksheet_With_Address_In_A1_PDF()
'Working only in 2007 and up
    Dim sh As Worksheet
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim FileName As String
    'Temporary path to save the PDF files
    'You can also use another folder like
    'TempFilePath = "C:\Users\Ron\MyFolder\"
    TempFilePath = Environ$("temp") & "\"
        Plan15.Range("EM76").Value = Now()
            TempFileName = TempFilePath & "Ordem de Compra Nº " & Plan15.Range("GY4").Value & " - " _
                         & Format(Now, "dd.mm.yyyy hh-mm-ss") & ".pdf"

            FileName = RDB_Create_PDF(Source:=Plan15, _
                                      FixedFilePathName:=TempFileName, _
                                      OverwriteIfFileExist:=True, _
                                      OpenPDFAfterPublish:=False)

            'If publishing is OK create the mail
            If FileName <> "" Then
                RDB_Mail_PDF_Outlook FileNamePDF:=FileName, _
                                     StrTo:=Plan15.Range("FW13").Value, _
                                     StrCC:="", _
                                     StrBCC:="", _
                                     StrImportance:=2, _
                                     StrSubject:="Solicitação DuPont Pioneer | " & Plan10.Range("F6") & " - " & Format(Now, "dd/mm"), _
                                     Signature:=True, _
                                     Send:=False, _
                                     StrBody:="<BODY style=font-size:11pt;font-family:calibri><b>Caro fornecedor,</b><p>Segue em anexo ordem de compra nº " & Plan15.Range("GY4").Value & ", favor enviar cotação para a mesma e aguardar ordem de envio.</BODY>"
            Else
                MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
                       "Microsoft Add-in is not installed" & vbNewLine & _
                       "You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
                       "The path to Save the file in arg 2 is not correct" & vbNewLine & _
                       "You didn't want to overwrite the existing PDF if it exist"
            End If
End Sub