mail attachments with VB? 
Author Message
 mail attachments with VB?

I use ole32 for create a mapi session

I have problem to attach files with Microsoft Outlook Client
My Files are Jpeg pictures and Access databases

If I remove de code between lines '******************
No errors occurs

My code is following

Tank You
Annie

'-------------------------------------------------------
Private Sub MapiStart()

    On Error GoTo MAPIStartErr
    '
    Set objSession = CreateObject("MAPI.Session")
    objSession.Logon ProfileName:="Microsoft Outlook", showdialog:=True

    Exit Sub
    '
MAPIStartErr:
    MsgBox Err.Number & Error$, vbInformation, "Erreur au login de la
messagerie"
    Erreur = 1
    '
End Sub

'-------------------------------------------------------
Public Sub CreerMessage()
    Dim objMessage As Object
    Dim objMessageColl As Object
    Dim objRecip As Object
    Dim objRecipColl As Object
    Dim objAttach As Object
    Dim objAttachColl As Object

    Dim NomFic As String
    Dim cpt As Integer

    cpt = 0

    '
    ' Crer un message, attacher les fichiers
    ' Afficher la fentre d'envoi
    '
    On Error Resume Next

    Set objMessageColl = objSession.Outbox.Messages
    Set objMessage = objMessageColl.Add
    objMessage.Subject = "MAJBDrep"

    ' Attache les fichiers
    NomFic = Dir(CheminBase & "Envois\FicEnvois\" & "*.*")

    '******************** Problem is here ********************
    ' Pour chaque fichier du dossier d'envoi
    Do While NomFic <> ""
        Set objAttachColl = objMessage.Attachments
        Set objAttach = objAttachColl.Add
'
        objAttach.Name = NomFic
        objAttach.Position = cpt
'
        objAttach.ReadFromFile = CheminBase & "envois\FicEnvois\" & NomFic
        cpt = cpt + 1
        NomFic = Dir
    Loop
    '************************************************************

    Set objRecipColl = objMessage.Recipients
    Set objRecip = objRecipColl.Add

'    objRecip.Type = 1
    objRecip.Name = Destinataire    ' Contient l'adresse E-mail du
destinataire
    objRecip.Resolve

    objMessage.Update

    objMessage.send showdialog:=True ' afficher la fentre
End Sub



Tue, 02 Jan 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. send mail attachment with VB

2. E-mail attachments with VB

3. E-mail attachments with VB

4. E-mail attachments with VB

5. E-mail attachments with VB

6. Attachments for e-mail in mail merge

7. vb launch default mail client with an attachment.

8. how to send mail with attachments via VB

9. VB and Mail Attachments

10. Send Mail with VB with attachments

11. save attachment of Mail in vb-program

12. Cannot send attachments files to Yahoo or Mail.Com from VB

 

 
Powered by phpBB® Forum Software