Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    problemi invio email tramite VB

    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

  2. #2
    Moderatore di Programmazione L'avatar di LeleFT
    Registrato dal
    Jun 2003
    Messaggi
    17,320

    Moderazione

    Per il linguaggio VB c'è un forum apposito: "Visual Basic e .NET Framework".
    Il titolo deve dare un'idea quanto più precisa possibile sul contenuto della discussione.
    Inoltre, è necessario specificare la versione di VB utilizzata.
    Ed il codice va postato indentato all'interno degli appositi tag CODE.

    Tutto questo lo trovi nel Regolamento interno.


    Sposto, correggo e modifico il post del codice.


    Ciao.
    "Perchè spendere anche solo 5 dollari per un S.O., quando posso averne uno gratis e spendere quei 5 dollari per 5 bottiglie di birra?" [Jon "maddog" Hall]
    Fatti non foste a viver come bruti, ma per seguir virtute e canoscenza

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.