Ciao a tutti.
Spero che qualcuno possa darmi una mano.
Ho scritto una macro per l'invio di email con allegati (utilizzando MAPI). Funziona tutto, con il solo problema che il file allegato viene recapitato al destinatario senza estensione, per cui il file xxxx.pdf viene recapitato come xxxx.
Qualcuno sa darmi una mano?
Grazie fin da ora.
Paolo
La macro è la seguente:
codice:
Sub Mail()
Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object
Dim sMsgTitle As String
Dim Attachment As Object
' Create the Session Object.
Set objSession = CreateObject("mapi.session")
' Log on using the session object.
' Specify a valid profile name if you want to
' avoid the logon dialog box.
objSession.Logon profileName:="Paolo SALADINI's mail on WS001060-01-MAI"
' Add a new message object to the OutBox.
Set objMessage = objSession.Outbox.Messages.Add
' Set the properties of the message object.
objMessage.Subject = "Statistica elaborazioni notturne"
objMessage.Text = "Si allega quanto in oggetto"
Set Attachment = objMessage.Attachments.Add
With Attachment
.Name = "invito.pdf"
.Type = FileData
.Source = "C:\invito.pdf"
.ReadFromFile Filename:="C:\invito.pdf"
'.Position = 0
End With
' Add a recipient object to the objMessage.Recipients collection.
Set objRecipient = objMessage.Recipients.Add
' Set the properties of the recipient object.
objRecipient.Name = "paolo.saladini@realemutua.it"
objRecipient.Resolve
' Send the message. Setting showDialog to False
' sends the message without displaying the message
' or requiring user intervention. A setting of True
' displays the message and the user must choose
' to Send from within the message dialog.
objMessage.Send showDialog:=False
MsgBox "Message sent successfully!"
' Log off using the session object.
objSession.Logoff
End Sub