Pagina precedente | 1 | Pagina successiva
Vota | Stampa | Notifica email    
Autore

kill file macro invia mail thunderbirds

Ultimo Aggiornamento: 22/07/2022 09:37
Post: 880
Registrato il: 28/12/2009
Città: CITTADELLA
Età: 62
Utente Senior
excel 2007/365
OFFLINE
16/07/2022 17:11

Provato con , ma non va

Dim DeleteFile As String

DeleteFile = TempFilePath & TempFileName & FileExtStr

If Len(Dir$(DeleteFile)) > 0 Then

SetAttr DeleteFile, vbNormal

Kill DeleteFile
End If



il file
TempFilePath & TempFileName & FileExtStr
dopo l'invio deve sparire


'Public Function fSendThunderbird()
Sub mail_thunder_xlsx()

    'Dim xRg1, xRg2 As Range
    Dim xRg1, xRg2 As Variant
    Dim xCell1, xCell2  As Range
    'Dim xEmailAddr As String
    'Dim emailAddr1, emailAddr2  As String
    Dim xTxt1, xTxt2 As String
    
    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
    Dim Ur As Long '<<< aggiunto
    Dim Avviso As String
    
    'Set Source = Nothing
    'On Error Resume Next


'---------------------------------------------------




    Dim strCommand As String ' Command line to prepare Thunderbird e-mail
    Dim strTo As String ' E-mail address
    Dim strCC As String 'E-mail address
    Dim strBcc As String 'E-mail address
    Dim strSubject As String ' Subject line
    Dim strBody As String ' E-mail body
    Dim strAttachment As String 'Allegati
   '-------------------------------------------------
    'Dim wk1 As Workbook
    'Dim miofile As String
    'Dim mioperc As String
    'Dim twb As String
    'Dim NomePDF As String
   '--------------------------------------------------
   
    Const cFormato As Integer = 1   '1: HTML    2:Plain Text

     
'-----------------------------------------------------------------------------------------
   
    If Range("A5") = "" Then
Avviso = MsgBox("non c'è niente da inviare via mail!", vbExclamation + vbOKOnly + vbDefaultButton2, "AVVISO")
 If Avviso = vbOK Then Exit Sub
 'End If
 End If
 
        
 Avviso = MsgBox("Gli indirizzi mail da selezionare sono nella colonna R", _
 vbInformation + vbOKOnly + vbDefaultButton2, "AVVISO!")
 'avviso = MsgBox("The email addresses to select are in column S", _
 'vbInformation + vbOKOnly + vbDefaultButton2, "INFORMATION!")
   
   
 
    
    
 '-----------------------------------------------------------------------------------------
           
    'strTo = Range("Z2").Value
    'strCC = Range("Z4").Value
    'strBcc = "test4@test.com"
    
    
 '-----------------------------------------------------------------------------------------
   'destinatari / '.To
   
    On Error Resume Next
    xTxt1 = ActiveWindow.RangeSelection.Address
    xTxt1 = Foglio13.Range("R5").Address
    
                           'strTo = Foglio11.Range("R5") '.Address
                           'Set xRg = Application.InputBox("Please select the arresses list:", "Kutools for Excel", xTxt, , , , , 8)
                           
    Set xRg1 = Application.InputBox("scegli i nomi utenti destinatari in colonna R" & Chr(13) & _
    "clicca CTRL nell'inputbox per inserire più utenti", "nomi utenti mail", xTxt1, , , , , 8)
    
    If xRg1 Is Nothing Then
    ActiveSheet.Protect "987654"
    Exit Sub
    End If
          
 '-----------------------------------------------------------------------------------------
 'per conoscenza / '.CC
    
    On Error Resume Next
    xTxt2 = ActiveWindow.RangeSelection.Address
    xTxt2 = Foglio13.Range("R5").Address
    
                           'strCC = Foglio11.Range("R5") '.Address
                           'Set xRg = Application.InputBox("Please select the arresses list:", "Kutools for Excel", xTxt, , , , , 8)
                           'Set xRg2 = Application.InputBox("scegli i nomi utenti per conoscenza in colonna S", "nomi utenti mail", xTxt2, , , , , 8)
    
     Set xRg2 = Application.InputBox("scegli i nomi utenti per conoscenza in colonna R " & Chr(13) & _
     "clicca CTRL nell'inputbox per inserire più utenti" & Chr(13) & _
     "clicca Annulla se non vuoi inviare", "nomi utenti mail", xTxt2, , , , , 8)
    
    'If xRg2 Is Nothing Then Exit Sub ' <<< tolto se non c'è niente
    
'-----------------------------------------------------------------------------------------
                       
                       
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
                       
                       
    '-----------------------------------------------------------------------------------------
    
      
    'Set Source = Range("A1:Q54").SpecialCells(xlCellTypeVisible) '<<< tutte righe del range
    
    Ur = Cells(Rows.Count, 3).End(xlUp).Row '<<< solo righe non vuote del range
    
    ActiveSheet.Unprotect "987654"
    
    Set Source = Range("A2:P" & Ur).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
        MsgBox "La sorgente non è un intervallo o il foglio è protetto, correggilo e riprova.", 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
        ActiveWindow.DisplayGridlines = False
        Application.CutCopyMode = False
        
    End With


    TempFilePath = Environ$("temp") & "\"
    TempFileName = "Selection of " & wb.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")

    If Val(Application.Version) < 12 Then
        'You use Excel 97-2003
        FileExtStr = ".xls": FileFormatNum = -4143
    Else
        'You use Excel 2007-2016
        FileExtStr = ".xlsx": FileFormatNum = 51
    End If
    
   
 '-----------------------------------------------------------------------------------------
 '-----------------------------------------------------------------------------------------
    With Dest
        
        .Worksheets(1).Cells.Locked = True
        .Worksheets(1).Protect password:="password"
        .Worksheets(1).EnableSelection = xlUnlockedCells
        .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
        
     On Error Resume Next
     
     End With
 '-----------------------------------------------------------------------------------------
 '-----------------------------------------------------------------------------------------
 'destinatari / '.To
 
    For Each xCell1 In xRg1
        If xCell1.Value Like "*@*" Then
           If strTo = "" Then
                strTo = xCell1.Value
            Else
               strTo = strTo & ";" & xCell1.Value
            End If
        End If
    Next
 '-----------------------------------------------------------------------------------------
 'per conoscenza / '.To
 
 If xRg2 <> "" Then
  
     For Each xCell2 In xRg2
        If xCell2.Value Like "*@*" Then
            If strCC = "" Then
                strCC = xCell2.Value
            Else
                strCC = strCC & ";" & xCell2.Value
            End If
        End If
    Next
    
    End If
 '-----------------------------------------------------------------------------------------
                           
                          
                         
    strAttachment = Dest.FullName
    
    strSubject = "ACTION di < " & Foglio13.Range("A2").Value & " >  "
    
    strBody = "ACTION < " & Foglio13.Range("D2").Value & " > "
                                 
    strCommand = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
  
    strCommand = strCommand & " -compose to='" & strTo & "'," _
        & "cc='" & strCC & "'," _
        & "bcc='" & strBcc & "'," _
        & "subject='" & strSubject & "'," _
        & "format='" & cFormato & "'," _
        & "body='" & strBody & "'," _
        & "attachment='" & strAttachment & "'"


 

Dim DeleteFile As String

DeleteFile = TempFilePath & TempFileName & FileExtStr

If Len(Dir$(DeleteFile)) > 0 Then

SetAttr DeleteFile, vbNormal

Kill DeleteFile
End If



With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
                            
    
    Call Shell(strCommand, vbNormalFocus)
  

 
End Sub
____________________________
versione excel 365 ufficio
versione excel 2007 casa
Vota:
Amministra Discussione: | Chiudi | Sposta | Cancella | Modifica | Notifica email Pagina precedente | 1 | Pagina successiva
Nuova Discussione
 | 
Rispondi
Cerca nel forum
Tag discussione
Discussioni Simili   [vedi tutte]
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 13:40. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com