Results 1 to 7 of 7

Thread: Email in access

  1. #1
    Join Date
    Aug 2004
    Posts
    23

    Question Unanswered: Email in access

    me again sorry

    I'm trying to send an email from access with an external attachment ie.

    c:\test.xls

    I'm using outlook, Is this possible?

    Thanks,

    Dave.

  2. #2
    Join Date
    Aug 2004
    Posts
    23
    I've managed to send an access element but so far unable to attach a XLS.

    Surely it can't be that difficult??

    and yes, i'm sorry for calling you surely

    D.

  3. #3
    Join Date
    Sep 2003
    Location
    Birmingham, UK
    Posts
    121
    You can use the 'MAPI' reference, can't give you the exact reference name as this will be dependant on your email client. For instance I use Outlook so my reference is called OutLook.10 Oblect Library. Do some digging to find yours.

    The code you require should be something like the following:

    Dim ObjOutlook As New Outlook.Application
    Dim ObjNameSpace As Outlook.NameSpace
    Dim ObjInbox As MAPIFolder
    Dim ObjMail As MailItem
    Dim ObjAttach As Attachment

    Set ObjNameSpace = ObjOutlook.GetNamespace("MAPI")

    Set ObjInbox = ObjNameSpace.GetDefaultFolder(olFolderDrafts)

    Set ObjMail = ObjInbox.Items.Add

    With ObjMail
    .Recipients.Add "MyAddress@stuff.co.uk"
    .Subject = "My new spreadsheet"
    .Attachments.Add "c:\myspreadsheet"
    .Display
    End With


    Hope this helps

  4. #4
    Join Date
    Aug 2004
    Posts
    23
    I'm assuming then that this line:

    Set ObjNameSpace = ObjOutlook.GetNamespace("MAPI")

    would then become

    Set ObjNameSpace = ObjOutlook.GetNamespace(outlook.10)

    I'm slightly confused as to where outlook.10 relates to your example?

    Thanks very much for your help BTW .

    Dave.

  5. #5
    Join Date
    Aug 2004
    Posts
    23
    Oh btw I'm using Outlook 2003.

    D.

  6. #6
    Join Date
    Sep 2003
    Location
    Birmingham, UK
    Posts
    121
    No the code stays the same. The reference that I'm referring to (?) can be found within the Access reference library. Open up any module or event procedure and click on the Tools tab, then click references and you should see and long list of all the possible references that you can choose. Find the Outlook ref and tick it to include it's objects in your current db.

  7. #7
    Join Date
    Aug 2004
    Posts
    23
    Thanks I've got it now

    Appreciate all your help.

    Dave.

Posting Permissions

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