ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   select file fro listbox and send via email (https://www.excelbanter.com/excel-programming/398958-select-file-fro-listbox-send-via-email.html)

sal21

select file fro listbox and send via email
 
I use this to piece of code to select from listbox2 the name of file
and send it vie email, but not work...
In effect all file are stored in this path:
OLDER_DOC = ("\\GCD01F4500\DATI\PUBBLICA\MODULI_GARANZIE\SERVI ZIO\" &
dire & "\" & sotto & "\")

Sub INVIO_MODULI()

Dim FileArr As Variant
Dim olApp As Object
Dim olMsg As Object
Dim F As Variant
Dim FOLDER_DOC As String

FOLDER_DOC = ("\\GCD01F4500\DATI\PUBBLICA\MODULI_GARANZIE\SERVI ZIO
\" & dire & "\" & sotto & "\")

Call SELEZIONE_MODULI(FileArr)

If FileArr = Empty Then
MsgBox "NESSUN FILE SELEZIONATO", vbCritical, "INVIO
CANCELLATO"
Exit Sub
End If

Set olApp = CreateObject("Outlook.Application")
Set olMsg = olApp.CreateItem(0)

With olMsg
.Body = "TEST MESSAGGIO"
.Subject = "TEST OGGETTO"

For Each F In FileArr
.Attachments.Add F
Next F

.Display
End With

Set olMsg = Nothing
Set olApp = Nothing

End Sub
Sub SELEZIONE_MODULI(FileArr)

Dim I As Integer
FileArr = ""
For I = 0 To UserForm3.ListBox2.ListCount - 1
If UserForm3.ListBox2.Selected(I) Then
FileArr = UserForm3.ListBox2.List(I)
End If
Next I

End Sub


dan dungan

select file fro listbox and send via email
 
Please clarify:

1. What excel version and operating system are you using?
2. Where, specifically does the procedure fail?
3. What is the error message?


On Oct 9, 6:21 am, sal21 wrote:
I use this to piece of code to select from listbox2 the name of file
and send it vie email, but not work...
In effect all file are stored in this path:
OLDER_DOC = ("\\GCD01F4500\DATI\PUBBLICA\MODULI_GARANZIE\SERVI ZIO\" &
dire & "\" & sotto & "\")

Sub INVIO_MODULI()

Dim FileArr As Variant
Dim olApp As Object
Dim olMsg As Object
Dim F As Variant
Dim FOLDER_DOC As String

FOLDER_DOC = ("\\GCD01F4500\DATI\PUBBLICA\MODULI_GARANZIE\SERVI ZIO
\" & dire & "\" & sotto & "\")

Call SELEZIONE_MODULI(FileArr)

If FileArr = Empty Then
MsgBox "NESSUN FILE SELEZIONATO", vbCritical, "INVIO
CANCELLATO"
Exit Sub
End If

Set olApp = CreateObject("Outlook.Application")
Set olMsg = olApp.CreateItem(0)

With olMsg
.Body = "TEST MESSAGGIO"
.Subject = "TEST OGGETTO"

For Each F In FileArr
.Attachments.Add F
Next F

.Display
End With

Set olMsg = Nothing
Set olApp = Nothing

End Sub
Sub SELEZIONE_MODULI(FileArr)

Dim I As Integer
FileArr = ""
For I = 0 To UserForm3.ListBox2.ListCount - 1
If UserForm3.ListBox2.Selected(I) Then
FileArr = UserForm3.ListBox2.List(I)
End If
Next I

End Sub





All times are GMT +1. The time now is 10:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com