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 CleuberZago
Posts
#14319
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
#14355
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
Por CleuberZago
Posts
#14368
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
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