Notifications
Clear all

inserir no assunto e no do body do e-mail a celula A1 do exc

16 Posts
3 Usuários
0 Reactions
3,906 Visualizações
(@carmelito)
Posts: 24
Eminent Member
Topic starter
 

boa tarde!
Será que podem me ajudar, preciso enviar um e-mail, criei uma planilha de excel, com um botão, o botão tem vários códigos, entre eles, o de enviar e-mail que segue, no entanto, preciso inserir no assunto o título: Segue em anexo o edital x ( :( x corresponde a célula A1 do arquivo criado).
e no body escrever: Segue o x (x é a célula A1 do arquivo criado) atualizado, favor, inserir o arquivo em anexo na intranet.
Obrigado.
Atenciosamente,
fulano.

Isso que eu queria que constasse no código abaixo, quem puder ajudar, será bem vindo.

Sub EnviarEmailPlanilhaEspecifica()
2 Dim NovoArquivoXLS As Workbook
3 Dim sPlanAEnviar As String
4 Dim sExcluirAnexoTemporario As String
5
6 'Define a planilha que será enviada por email. Ex.: Plan1, Balancete, Lista De Nomes, etc
7 sPlanAEnviar = "Plan1"
8
9 'Cria um novo arquivo excel
10 Set NovoArquivoXLS = Application.Workbooks.Add
11
12 'Copia a planilha para o novo arquivo criado
13 ThisWorkbook.Sheets(sPlanAEnviar).Copy Before:=NovoArquivoXLS.Sheets(1)
14
15 'Salva o arquivo
16 NovoArquivoXLS.SaveAs ThisWorkbook.Path & "" & sPlanAEnviar & ".xls"
17 sExcluirAnexoTemporario = NovoArquivoXLS.FullName
18
19 'Envia o email
20 NovoArquivoXLS.SendMail "xxxx@xxx.x", "Título do Email teste"
21
22 'Fecha o arquivo novo
23 NovoArquivoXLS.Close
24
25 'Exclui o arquivo criado apenas para ser enviado.
26 Kill sExcluirAnexoTemporario
'27 Sheets("Plan1").cell.ClearContents
28 End Sub
 
Postado : 28/01/2013 1:08 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa tarde!
Enquanto o pessoal não te dê uma resposta mais precisa...

Eu não uso excel para nada, ainda mais agora (que fui promovido para o TI-Infra), eu usava muito quando era do controle de estoque, tem coisas que nunca usei dentro dessa ferramenta poderosa, mais segue ai algo que talvez possa ajuda-lo

Sub TenteAdaptar() 
     
    Dim olApp As Outlook.Application 
    Dim olNs As Outlook.Namespace 
    Dim olFldr As Outlook.MAPIFolder 
    Dim olItms As Outlook.Items 
    Dim olMail As Variant 
    Dim i As Long 
     
    Set olApp = New Outlook.Application 
    Set olNs = olApp.GetNamespace(”MAPI”) 
    Set olFldr = olNs.GetDefaultFolder(olFolderInbox) 
    Set olItms = olFldr.Items 
     
    olItms.Sort “Subject” 
     
    i = 1 
     
    For Each olMail In olItms 
        If InStr(olMail.Subject, “[COLOR="green"]Criteria[/COLOR]”) > 0 Then 
            [COLOR="green"]ThisWorkbook[/COLOR].Sheets("[COLOR="green"]YourSheet[/COLOR]").Cells(i, 1).Value = outMail.Body 
            i = i + 1 
        End If 
    Next olMail 
     
    Set olFldr = Nothing 
    Set olNs = Nothing 
    Set olApp = Nothing 
     
End Sub 

Leia também:
http://msdn.microsoft.com/en-us/library ... =office.11).aspx
http://www.cpearson.com/excel/Email.aspx

Sub EMail_PlanilhaAtiva() 
     'Working in 2000-2007
    Dim Source As Range 
    Dim Dest As Workbook 
    Dim wb As Workbook 
    Dim TempFilePath As String 
    Dim TempFileName As String 
    Dim FileExtStr As String 
    Dim FileFormatNum As Long 
    Dim OutApp As Object 
    Dim OutMail As Object 
     
    Set Source = Nothing 
    On Error Resume Next 
     
    Set Source = Sheets("Charity Calendar").Range("A1:At91").SpecialCells(xlCellTypeVisible) 
     
    On Error Goto 0 
     
    If Source Is Nothing Then 
        MsgBox "The source is not a range or the sheet is protected, please correct and try again.", vbOKOnly 
        Exit Sub 
    End If 
     
    With Application 
        .ScreenUpdating = False 
        .EnableEvents = False 
    End With 
     
    Set wb = ActiveWorkbook 
    Set Dest = Workbooks.Add(xlWBATWorksheet) 
    Source.Copy 
     
    With Dest.Sheets(1) 
         
        .Cells(1).PasteSpecial Paste:=8 
        .Cells(1).PasteSpecial Paste:=xlPasteValues 
        .Cells(1).PasteSpecial Paste:=xlPasteFormats 
        .Cells(1).Select 
        Application.CutCopyMode = False 
    End With 
     
    TempFilePath = Environ$("temp") & "" 
    TempFileName = Sheets("email data").Range("c11") & " " & Format(Now, "dd-mmm-yy ") 
     
    If Val(Application.Version) < 12 Then 
         'You use Excel 2000-2003
        FileExtStr = ".xls": FileFormatNum = -4143 
    Else 
         'You use Excel 2007
        FileExtStr = ".xlsx": FileFormatNum = 51 
    End If 
     
    Set OutApp = CreateObject("Outlook.Application") 
    OutApp.Session.Logon 
    Set OutMail = OutApp.CreateItem(0) 
     
    With Dest 
        .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum 
        On Error Resume Next 
        With OutMail 
            .To = Sheets("email data").Range("C9") 
            .CC = Sheets("email data").Range("C12") & "; " & Sheets("email data").Range("C13") & "; " & Sheets("email data").Range("C14") & "; " & Sheets("email data").Range("C15") 
            .BCC = Sheets("email data").Range("C16") 
            .Subject = Sheets("email data").Range("C11") 
             
            .Body = "F.A.O" & " " & Sheets("email data").Range("C17") & vbNewLine & vbNewLine & _ 
            Sheets("email data").Range("C18") & vbNewLine & vbNewLine & _ 
            Sheets("email data").Range("C19") & vbNewLine & _ 
            Sheets("email data").Range("C20") & vbNewLine & _ 
            Sheets("email data").Range("C21") & vbNewLine & _ 
            Sheets("email data").Range("C22") & vbNewLine & _ 
            Sheets("email data").Range("C23") & vbNewLine & _ 
            Sheets("email data").Range("C24") & vbNewLine & _ 
            Sheets("email data").Range("C25") & vbNewLine & _ 
            Sheets("email data").Range("C26") & vbNewLine & _ 
            Sheets("email data").Range("C27") & vbNewLine & _ 
            Sheets("email data").Range("C28") & vbNewLine & _ 
            Sheets("email data").Range("C29") & vbNewLine & _ 
            Sheets("email data").Range("C30") & vbNewLine & _ 
            Sheets("email data").Range("C31") & vbNewLine & _ 
            Sheets("email data").Range("C32") & vbNewLine & _ 
            Sheets("email data").Range("C33") & vbNewLine & _ 
            Sheets("email data").Range("C34") & vbNewLine & _ 
            Sheets("email data").Range("C35") & vbNewLine & _ 
            Sheets("email data").Range("C36") & vbNewLine & _ 
            Sheets("email data").Range("C37") & vbNewLine & _ 
            "" & vbNewLine & vbNewLine 
             ' .Attachments.Add Destwb.FullName
            .Attachments.Add Dest.FullName 
             
             'You can add other files also like this
             '.Attachments.Add ("C:test.txt")
            .Send 
             '.Display
        End With 
        On Error Goto 0 
        .Close SaveChanges:=False 
         
    End With 
     
    Kill TempFilePath & TempFileName & FileExtStr 
     
    Set OutMail = Nothing 
    Set OutApp = Nothing 
     
    With Application 
        .ScreenUpdating = True 
        .EnableEvents = True 
    End With 
     
     
End Sub 

Att

 
Postado : 28/01/2013 1:18 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Grande Alexandre,
parabens pela promoção. :!: :D

 
Postado : 28/01/2013 1:36 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa noite!!
Obrigado Mestre Reinaldo!!!
Essa nova caminhada até então é minha melhor oportunidade que já me apareceu:D

Att

 
Postado : 28/01/2013 5:09 pm
(@carmelito)
Posts: 24
Eminent Member
Topic starter
 

Obrigado, mas é muito complexo pra minha cabeça, fiz os testes mas não consegui, vou ver se alguém tem outra ideia.
Parabéns, amigo, pela promoção, também não uso excel, eu faço os programinhas tudo em access, porém, como existe esse arquivo há muito tempo, e agora temos que colocar ele na intranet, diariamente, então pensei em ajudar a pessoa que trabalha nisso, criando esse botão pra fazer tudo automático, mas não sabia que ia dar tanto trabalho pra você. Mais uma vez, muito obrigado, não vou encerrar o forum, pois preciso de ajuda, vamos ver outras pessoas, com outras ideias, mas tu me deu uma grande mao no filtro do excel, ficou show.
até.

 
Postado : 28/01/2013 7:00 pm
(@gamboaisrael)
Posts: 68
Trusted Member
 

Carmelito,

Utilizei o seu código como base e só inseri mais algumas linhas. Então, substitua o código que você postou aqui por este abaixo:

Sub EnviarEmailPlanilhaEspecifica()
Dim NovoArquivoXLS As Workbook
Dim sPlanAEnviar As String
Dim sExcluirAnexoTemporario As String
Dim objOlAppApp As Outlook.Application
Dim objOlAppMsg As Outlook.MailItem
Dim objOlAppRecip As Outlook.Recipient
Dim objOlAppAnexo As Outlook.Attachment
Dim Destinatario As String
Dim x As String

'Define a planilha que será enviada por email. Ex.: Plan1, Balancete, Lista De Nomes, etc
sPlanAEnviar = "Plan1"

'Cria um novo arquivo excel
Set NovoArquivoXLS = Application.Workbooks.Add

'Copia a planilha para o novo arquivo criado
ThisWorkbook.Sheets(sPlanAEnviar).Copy Before:=NovoArquivoXLS.Sheets(1)

'Salva o arquivo
NovoArquivoXLS.SaveAs ThisWorkbook.Path & "" & sPlanAEnviar & ".xls"
sExcluirAnexoTemporario = NovoArquivoXLS.FullName

'Aqui começa o envio do email:
'Criar objeto do outlook
Set objOlAppApp = CreateObject("Outlook.Application")
Set objOlAppMsg = objOlAppApp.CreateItem(olMailItem)

'Determina o destinatário
Destinatario = "coloqueaquioemaildodestinatario@email.com.br"

'Determina o x
x = Range("A1").Value
    
With objOlAppMsg
'Email do destinatário
Set objOlAppRecip = .Recipients.Add(Destinatario)
objOlAppRecip.Type = olTo
'Grau de importância do email
.Importance = olImportanceNormal
'Cabeçalho do email
.Subject = ("Segue em anexo o edital " & x)
'Texto do email
.Body = "Segue o " & x & " atualizado, favor, inserir o arquivo em anexo na intranet." & vbCrLf & "Obrigado." & vbCrLf & "Atenciosamente,"
'Enviar email
.Send
End With
    
MsgBox "E-mail enviado com sucesso!", vbOKOnly, "Aviso"

'Fecha o arquivo novo
NovoArquivoXLS.Close

'Exclui o arquivo criado apenas para ser enviado.
Kill sExcluirAnexoTemporario

'Sheets("Plan1").cell.ClearContents
End Sub

Faça os testes e dê retorno!

Att.,

 
Postado : 29/01/2013 5:33 am
(@gamboaisrael)
Posts: 68
Trusted Member
 

Meu caro, percebi que no código anterior eu havia esquecido de inserir a linha para anexar a planilha!

Segue agora o correto:

Sub EnviarEmailPlanilhaEspecifica()
Dim NovoArquivoXLS As Workbook
Dim sPlanAEnviar As String
Dim sExcluirAnexoTemporario As String
Dim objOlAppApp As Outlook.Application
Dim objOlAppMsg As Outlook.MailItem
Dim objOlAppRecip As Outlook.Recipient
Dim Destinatario As String
Dim x As String

'Define a planilha que será enviada por email. Ex.: Plan1, Balancete, Lista De Nomes, etc
sPlanAEnviar = "Plan1"

'Cria um novo arquivo excel
Set NovoArquivoXLS = Application.Workbooks.Add

'Copia a planilha para o novo arquivo criado
ThisWorkbook.Sheets(sPlanAEnviar).Copy Before:=NovoArquivoXLS.Sheets(1)

'Salva o arquivo
NovoArquivoXLS.SaveAs ThisWorkbook.Path & "" & sPlanAEnviar & ".xls"
sExcluirAnexoTemporario = NovoArquivoXLS.FullName

'Aqui começa o envio do email:
'Criar objeto do outlook
Set objOlAppApp = CreateObject("Outlook.Application")
Set objOlAppMsg = objOlAppApp.CreateItem(olMailItem)

'Determina o destinatário
Destinatario = "coloqueaquioemaildodestinatario@email.com.br"

'Determina o x
x = Range("A1").Value
    
With objOlAppMsg
'Email do destinatário
Set objOlAppRecip = .Recipients.Add(Destinatario)
objOlAppRecip.Type = olTo
'Anexa o arquivo
.Attachments.Add (sExcluirAnexoTemporario)
'Grau de importância do email
.Importance = olImportanceNormal
'Cabeçalho do email
.Subject = ("Segue em anexo o edital " & x)
'Texto do email
.Body = "Segue o " & x & " atualizado, favor, inserir o arquivo em anexo na intranet." & vbCrLf & "Obrigado." & vbCrLf & "Atenciosamente,"
'Enviar email
.Send
End With
    
MsgBox "E-mail enviado com sucesso!", vbOKOnly, "Aviso"

'Fecha o arquivo novo
NovoArquivoXLS.Close

'Exclui o arquivo criado apenas para ser enviado.
Kill sExcluirAnexoTemporario

'Sheets("Plan1").cell.ClearContents
End Sub

É importante ressaltar, também, que você precisa inserir a referência Microsoft Outlook XX.x Object Library ao seu projeto. Ok?
Se tiver dúvida sobre como fazer isso, leia este tutorial: http://www.ambienteoffice.com.br/office ... bliotecas/

No mais, siga as mesmas instruções da mensagem anterior.

Att.,

 
Postado : 29/01/2013 6:38 am
(@carmelito)
Posts: 24
Eminent Member
Topic starter
 

Muito obrigado Gamboaisrael, só tem mestres neste fórum, parabéns, ficou perfeito, só abusando da bondade, tem como colocar a célula A1, também no nome do arquivo que vai em anexo no outlook.
não sei se é aqui que eu coloco a célula A1
'Define a planilha que será enviada por email. Ex.: Plan1, Balancete, Lista De Nomes, etc
sPlanAEnviar = "Plan1"

ou aqui,

'Salva o arquivo
NovoArquivoXLS.SaveAs ThisWorkbook.Path & "" & sPlanAEnviar & ".xls"
sExcluirAnexoTemporario = NovoArquivoXLS.FullName

coloquei: & Range("A1").Value & mas não deu. queria o nome do arquivo que tivesse em anexo: Plan1(espaço) (e o que estiver escrito na célula A1).xls

muito obrigado.

 
Postado : 29/01/2013 8:44 am
(@gamboaisrael)
Posts: 68
Trusted Member
 

Boa tarde, Carmelito.

Tente substituir a linha abaixo:

'Salva o arquivo
NovoArquivoXLS.SaveAs ThisWorkbook.Path & "" & sPlanAEnviar & ".xls"
sExcluirAnexoTemporario = NovoArquivoXLS.FullName

Pela linha:

'Determina o x
x = Range("A1").Value

'Salva o arquivo
NovoArquivoXLS.SaveAs ThisWorkbook.Path & "" & sPlanAEnviar & "" & x & ".xls"
sExcluirAnexoTemporario = NovoArquivoXLS.FullName

É importante que você apague a linha 'Determina o x da parte de baixo do código (aonde ela estava).

O código completo fica assim:

Sub EnviarEmailPlanilhaEspecifica()
Dim NovoArquivoXLS As Workbook
Dim sPlanAEnviar As String
Dim sExcluirAnexoTemporario As String
Dim objOlAppApp As Outlook.Application
Dim objOlAppMsg As Outlook.MailItem
Dim objOlAppRecip As Outlook.Recipient
Dim Destinatario As String
Dim x As String

'Define a planilha que será enviada por email. Ex.: Plan1, Balancete, Lista De Nomes, etc
sPlanAEnviar = "Plan1"

'Cria um novo arquivo excel
Set NovoArquivoXLS = Application.Workbooks.Add

'Copia a planilha para o novo arquivo criado
ThisWorkbook.Sheets(sPlanAEnviar).Copy Before:=NovoArquivoXLS.Sheets(1)

'Determina o x
x = Range("A1").Value

'Salva o arquivo
NovoArquivoXLS.SaveAs ThisWorkbook.Path & "" & sPlanAEnviar & "" & x & ".xls"
sExcluirAnexoTemporario = NovoArquivoXLS.FullName

'Aqui começa o envio do email:
'Criar objeto do outlook
Set objOlAppApp = CreateObject("Outlook.Application")
Set objOlAppMsg = objOlAppApp.CreateItem(olMailItem)

'Determina o destinatário
Destinatario = "coloqueaquioemaildodestinatario@email.com.br"
    
With objOlAppMsg
'Email do destinatário
Set objOlAppRecip = .Recipients.Add(Destinatario)
objOlAppRecip.Type = olTo
'Anexa o arquivo
.Attachments.Add (sExcluirAnexoTemporario)
'Grau de importância do email
.Importance = olImportanceNormal
'Cabeçalho do email
.Subject = ("Segue em anexo o edital " & x)
'Texto do email
.Body = "Segue o " & x & " atualizado, favor, inserir o arquivo em anexo na intranet." & vbCrLf & "Obrigado." & vbCrLf & "Atenciosamente,"
'Enviar email
.Send
End With
    
MsgBox "E-mail enviado com sucesso!", vbOKOnly, "Aviso"

'Fecha o arquivo novo
NovoArquivoXLS.Close

'Exclui o arquivo criado apenas para ser enviado.
Kill sExcluirAnexoTemporario

'Sheets("Plan1").cell.ClearContents
End Sub

Se a ajuda lhe atendeu, marque o tópico como resolvido e dá um joinha ai! ;)

Att.,

 
Postado : 29/01/2013 9:20 am
(@carmelito)
Posts: 24
Eminent Member
Topic starter
 

será que tem que ativar alguma referência no excel 2003, pois agora apareceu a mensagem a seguir, e não enviou o arquivo, depois ele aberto no micro, mas não enviou.
Erro em tempo de execução ‘1004’:
O Microsoft Office Excel não pode acessar o arquivo
‘c:userscarmelitodesktopPlan1editalx’. Há várias razões possíveis:
O nome do arquivo ou caminho não existe.
O arquivo está sendo usado por outro programa.
O nome da pasta de trabalho que você está tentando salvar é o

 
Postado : 29/01/2013 12:24 pm
(@carmelito)
Posts: 24
Eminent Member
Topic starter
 

Achei o motivo, pois na célula consta o texto edital nºx/2013, lógico, o windows não aceita / no nome do arquivo. Tudo bem, só coloquei um texto pra testar, então aparece esse erro:
Erro em tempo de execução ‘-1940897787 (8c504005)’: O Outlook não reconhece um ou mais nomes.

e ao depurar o código aparece problema no
.Send

será que vc tem alguma ideia ou alguém?

 
Postado : 29/01/2013 12:39 pm
(@carmelito)
Posts: 24
Eminent Member
Topic starter
 

olha só que estranho, se eu trocar .Send para .display, ele abre o outlook com o arquivo anexado, tudo certo, no entanto, tenho que clicar no botão enviar pra enviar o email, será que tem uma forma pra enviar com o .send, sem precisar abrir na tela!?

 
Postado : 29/01/2013 12:48 pm
(@gamboaisrael)
Posts: 68
Trusted Member
 

Carmelito,

O que eu já vi ocorrer no Office 2003, é que quando o Outlook também é 2003, ele fica dando uma mensagem de alerta de segurança sempre que o e-mail está para ser enviado. Mas isso é simples de resolver. Basta inserir o código abaixo no módulo 'ThisOutlookSession' do Outlook 2003. (Ps.: Fonte do código abaixo: http://www.everythingaccess.com/tutorials.asp?ID=112 )

Option Explicit

' Enviar e-mail sem alertas de segurança
' Inserir no módulo 'ThisOutlookSession' do MS Outlook 2003
' Please read the full tutorial here:
' http://www.everythingaccess.com/tutorials.asp?ID=112


Private Sub Application_Startup()

    'IGNORE - This forces the VBA project to open and be accessible 
    '         using automation at any point after startup

End Sub

' FnSendMailSafe
' --------------
' Simply sends an e-mail using Outlook/Simple MAPI.
' Calling this function by Automation will prevent the warnings
' 'A program is trying to send a mesage on your behalf...'
' Also features optional HTML message body and attachments by file path. 
'
' The To/CC/BCC/Attachments function parameters can contain multiple items 
' by seperating them with a semicolon. (e.g. for the strTo parameter, 
' 'test@test.com; test2@test.com' would be acceptable for sending to 
' multiple recipients. 
'                   
Public Function FnSendMailSafe(strTo As String, _
                                strCC As String, _
                                strBCC As String, _
                                strSubject As String, _
                                strMessageBody As String, _
                                Optional strAttachments As String) As Boolean

' (c) 2005 Wayne Phillips - Written 07/05/2005
' Last updated 26/03/2008 - Bugfix for empty recipient strings
' http://www.everythingaccess.com
'
' You are free to use this code within your application(s)
' as long as the copyright notice and this message remains intact.

On Error GoTo ErrorHandler:

    Dim MAPISession As Outlook.NameSpace
    Dim MAPIFolder As Outlook.MAPIFolder
    Dim MAPIMailItem As Outlook.MailItem
    Dim oRecipient As Outlook.Recipient
    
    Dim TempArray() As String
    Dim varArrayItem As Variant
    Dim strEmailAddress As String
    Dim strAttachmentPath As String
    
    Dim blnSuccessful As Boolean

    'Get the MAPI NameSpace object
    Set MAPISession = Application.Session
    
    If Not MAPISession Is Nothing Then

      'Logon to the MAPI session
      MAPISession.Logon , , True, False

      'Create a pointer to the Outbox folder
      Set MAPIFolder = MAPISession.GetDefaultFolder(olFolderOutbox)
      If Not MAPIFolder Is Nothing Then

        'Create a new mail item in the "Outbox" folder
        Set MAPIMailItem = MAPIFolder.Items.Add(olMailItem)
        If Not MAPIMailItem Is Nothing Then
          
          With MAPIMailItem

            'Create the recipients TO
                TempArray = Split(strTo, ";")
                For Each varArrayItem In TempArray
                
                    strEmailAddress = Trim(varArrayItem)
                    If Len(strEmailAddress) > 0 Then
                        Set oRecipient = .Recipients.Add(strEmailAddress)
                        oRecipient.Type = olTo
                        Set oRecipient = Nothing
                    End If
                
                Next varArrayItem
            
            'Create the recipients CC
                TempArray = Split(strCC, ";")
                For Each varArrayItem In TempArray
                
                    strEmailAddress = Trim(varArrayItem)
                    If Len(strEmailAddress) > 0 Then
                        Set oRecipient = .Recipients.Add(strEmailAddress)
                        oRecipient.Type = olCC
                        Set oRecipient = Nothing
                    End If
                
                Next varArrayItem
            
            'Create the recipients BCC
                TempArray = Split(strBCC, ";")
                For Each varArrayItem In TempArray
                
                    strEmailAddress = Trim(varArrayItem)
                    If Len(strEmailAddress) > 0 Then
                        Set oRecipient = .Recipients.Add(strEmailAddress)
                        oRecipient.Type = olBCC
                        Set oRecipient = Nothing
                    End If
                
                Next varArrayItem
            
            'Set the message SUBJECT
                .Subject = strSubject
            
            'Set the message BODY (HTML or plain text)
                If StrComp(Left(strMessageBody, 6), "<HTML>", _
                            vbTextCompare) = 0 Then
                    .HTMLBody = strMessageBody
                Else
                    .Body = strMessageBody
                End If

            'Add any specified attachments
                TempArray = Split(strAttachments, ";")
                For Each varArrayItem In TempArray
                
                    strAttachmentPath = Trim(varArrayItem)
                    If Len(strAttachmentPath) > 0 Then
                        .Attachments.Add strAttachmentPath
                    End If
                
                Next varArrayItem

            .Send 'The message will remain in the outbox if this fails

            Set MAPIMailItem = Nothing
            
          End With

        End If

        Set MAPIFolder = Nothing
      
      End If

      MAPISession.Logoff
      
    End If
    
    'If we got to here, then we shall assume everything went ok.
    blnSuccessful = True
    
ExitRoutine:
    Set MAPISession = Nothing
    FnSendMailSafe = blnSuccessful
    
    Exit Function
    
ErrorHandler:
    MsgBox "An error has occured in the user defined Outlook VBA function " & _
            "FnSendMailSafe()" & vbCrLf & vbCrLf & _
            "Error Number: " & CStr(Err.Number) & vbCrLf & _
            "Error Description: " & Err.Description, _
                vbApplicationModal + vbCritical
    Resume ExitRoutine

End Function

Já este erro que você relatou eu não tenho como testar aqui, pois só tenho acesso a PC's com Office 2010, tanto em casa quanto no trabalho.

 
Postado : 29/01/2013 1:16 pm
(@carmelito)
Posts: 24
Eminent Member
Topic starter
 

muito obrigado amigão, o problema era na configuração do email do destinário, coloquei errado, heheh, obrigado mesmo, ajuda foi muito grande pra mim e para o pessoal do setor. Valeu.

 
Postado : 29/01/2013 1:24 pm
(@gamboaisrael)
Posts: 68
Trusted Member
 

muito obrigado amigão, o problema era na configuração do email do destinário, coloquei errado, heheh, obrigado mesmo, ajuda foi muito grande pra mim e para o pessoal do setor. Valeu.

Fico feliz que tenha dado certo! :D

Atenciosamente,

 
Postado : 29/01/2013 1:25 pm
Página 1 / 2