Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Attachement path (Access 2000)

    I have been given a module for sending an email with the content in a text format.I am pasting this module below.In the OnClick event in the form i have written :
    SendMessage "C:My DocumentsCustomers.txt"
    When clicking i get the message "Path does not exist.Make sure the path is correct." The error points to "AttachementPath|. Where can i enter the address of the recipient of the email ?

    Thank you in advance


    Sub SendMessage(Optional AttachmentPath)
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.Attachment

    ' Create the Outlook session.
    Set objOutlook = CreateObject("Outlook.Application")

    ' Create the message.
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
    ' Add the To recipient(s) to the message.
    Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
    objOutlookRecip.Type = olTo

    ' Add the CC recipient(s) to the message.
    Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
    objOutlookRecip.Type = olCC

    ' Set the Subject, Body, and Importance of the message.
    .Subject = "This is an Automation test with Microsoft Outlook"
    .Body = "Last test - I promise." & vbCrLf & vbCrLf
    .Importance = olImportanceHigh 'High importance

    ' Add attachments to the message.
    If Not IsMissing(AttachmentPath) Then
    Set objOutlookAttach = .Attachments.Add(AttachmentPath)
    End If

    ' Resolve each Recipient's name.
    For Each objOutlookRecip In .Recipients
    objOutlookRecip.Resolve
    If Not objOutlookRecip.Resolve Then
    objOutlookMsg.Display
    End If
    Next
    .Send

    End With
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
    End Sub

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Attachement path (Access 2000)

    The problem here is that "C:My DocumentsCustomers.txt" does not exist.

    You may have Customer.txt in the My Documents folder, but this is not usually directly on the C drive. Usually it is buried within cocuments and Settings , but this can be changed.

    You code will try to send the message ,and attachment, to Nancy Davolio and Andrew Fuller . The Resolve code will look up their addresses.
    Regards
    John



  3. #3
    3 Star Lounger
    Join Date
    Mar 2006
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    289
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Attachement path (Access 2000)

    Above the line 'Add attachments to the message' write
    Set AttachmentPath = "The path" (for example "Cocuments and SettingsDefault UserMy Documents")
    Thanks
    chuck

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Attachement path (Access 2000)

    Because this function is defined as

    Sub SendMessage(Optional AttachmentPath)

    it expects the AttachmentPath (if there is one) to be passed as a parameter.
    Regards
    John



  5. #5
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Attachement path (Access 2000)

    Thank you to you all. Where cold i write the attachement path as a parameter ?

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Attachement path (Access 2000)

    When you use

    SendMessage "C:My DocumentsCustomers.txt"

    you are passing the attachment as a parameter, but you are using an incorrect value.

    You need to find the real location of My Documents and use that.
    Regards
    John



Posting Permissions

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