Results 1 to 14 of 14

Thread: Problem with attaching files using MAPI in VB??

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    S.A
    Posts
    15

    Talking

    the app send an email message but it won't attach a file to the email. Here is the code I am using to attach the file.
    I don't know if I am using this right or not.

    Dim objSession As MAPI.Session
    Dim objMessage As MAPI.Message

    'create a message and fill in its properties
    Set objMessage = objSession.Outbox.Messages.Add
    objMessage.Subject = txtSubject.Text
    objMessage.Text = txtMessage.Text
    objMessage.Attachments.Add "C:\file.dat"
    can brown cows fly???

  2. #2
    Guest

    Adding attachment

    Hi ,

    I think you should add the following code to your current code:

    objMessage.Update

    This is because you did something new to the current message

    Michiel


  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    S.A
    Posts
    15

    operation failed

    when I try and open the email doc I get the following error.

    Can't Open this mail, the operation failed.

    Clueless right know as to what the problem is
    can brown cows fly???

  4. #4
    Guest

    Opening Email

    Can you be a little bit more specific?

  5. #5
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752

    Thumbs up

    objMessage.Attachments.Add "C:\file.dat"...is this the correct way?

    i think it is like this..

    objMessage.AttachmentIndex=0
    objMessage.AttachmentName=somename 'as u wish
    objMessage.AttachmentPathName=filepath
    ' if u want more

    objMessage.AttachmentIndex=1
    objMessage.AttachmentName=somename 'as u wish
    objMessage.AttachmentPathName=filepath


    Hope this helps
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    S.A
    Posts
    15

    code don't work

    I tried the example but she still broken, except know I am getting a runtime error, 486 - object does'nt support this method....
    can brown cows fly???

  7. #7
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752
    If u want I will send u a sample application that does this.

    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    S.A
    Posts
    15

    YEEESSS PLLEEEZZZ

    Please Please

    thanks
    can brown cows fly???

  9. #9
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752

    Thumbs up

    This will work ..I think...


    With objMessage.Attachments.Add
    .Position = 1
    .Type = mapiFileData
    .Name = Attach 'name of attachment
    .ReadFromFile Attach 'pathname
    End With
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  10. #10
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752

    Try this

    Try the above code. Thats working on my machine. If I send u the whole application u will be confused. I think this is what u want. However if u really want just mail me
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  11. #11

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    S.A
    Posts
    15

    Question postion no...

    what is the postion number for though???
    can brown cows fly???

  12. #12
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752
    Thats for setting where to put the attachment in the message. By the way is it working?
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  13. #13

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Location
    S.A
    Posts
    15

    Thumbs up yep thank

    Thank,

    The code worked like a dream, one question though
    where can i get my hand on a mapi tutorial.
    can brown cows fly???

  14. #14
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752
    You could find it on MSDN. I got it from there.
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width