select file fro listbox and send via email

S

sal21

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\SERVIZIO\" &
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\SERVIZIO
\" & 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
 
D

dan dungan

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top