Ir para conteúdo
Fórum Script Brasil
  • 0

VBA associar arquivos ao endereco de email


Luccaslpn

Pergunta

tenho um script em vba, que salva todos os anexos que contem dentro de determinado email, gostaria de fazer uma ligação desses anexos com o endereco de que envio os anexo, criar uma pasta com o nome do endereco de email, e enviar os anexos para ela, segue meu codigo em vba, se alguém poder me ajudar.

 

 

Public Sub AttachmentIndex()
Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim strFile As String
Dim strFolderpath As String
Dim strDeletedFiles As String
         
    Dim sAppName As String
    Dim sSection As String
    Dim sKey As String
    Dim lRegValue As Long
    Dim lFormValue As Long
    Dim iDefault As Integer
     
    sAppName = "Outlook"
    sSection = "Index"
    sKey = "Last Index Number"
     iDefault = 101
  
     lRegValue = GetSetting(sAppName, sSection, sKey, iDefault)
  
     If lRegValue = 0 Then lRegValue = iDefault
 
    strFolderpath = CreateObject("WScript.Shell").SpecialFolders(16)
    On Error Resume Next
 
    Set objOL = Application
    Set objSelection = objOL.ActiveExplorer.Selection
 
 
     strFolderpath = "C:\Temp\Anexos Outlook\"
 
    For Each objMsg In objSelection
 
    Set objAttachments = objMsg.Attachments
    lngCount = objAttachments.Count
         
    If lngCount > 0 Then
    For i = lngCount To 1 Step -1
    strFile = objAttachments.Item(i).FileName
    
    lcount = InStrRev(strFile, ".") - 1
    pre = Left(strFile, lcount)
    ext = Right(strFile, Len(strFile) - lcount)
    strFile = strFolderpath & pre & "_" & lRegValue & ext

    objAttachments.Item(i).SaveAsFile strFile
  
    lRegValue = lRegValue + 1
        Err.Clear
    Next
     
     SaveSetting sAppName, sSection, sKey, lRegValue
 
    End If
     
    Next
    
ExitSub:
   
Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing

End Sub

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,7k
×
×
  • Criar Novo...