Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004

    Unanswered: Email file which is saved in a folder

    I have a field (hyperlink) called 'FileLocation'

    The actual file location is C:\MyFolder\myfile.xls

    How to open outlook and attach this file, with one click on my form?


  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland
    no takers?

    here's what i was using ten years ago.
    i have absolutely no idea if it will fly with current Outlook versions but at least it shows you what used to work.

    stick it in a code module and see what goes wrong


    Option Compare Database
    Option Explicit
    ''  Module izyMailer
    ''  izyrider, 2004
    ''  Late-bind Outlook mailer (does NOT need a reference to Outlook)
    ''  Depending on your Outlook version and configuration, Outlook may block auto-mailing
    ''  attempts. Simplest work-around is to display the mail ready-to-send and leave the
    ''  user to press the [Send] button.
    'constants for izyMailer
    Global Const izymailer_Draft = 1	'mail will be saved as a Draft
    Global Const izymailer_Display = 2	'mail will be displayed in Outlook ready-to-send
    Global Const izymailer_Send = 3		'mail will be sent automatically (if Outlook does not block auto-mail)
    Const imCstOLMailItem = 0		'an Outlook constant for "mail item"
    Public Function izyMailer(isMode As Integer, isTo As String, isSubj As String, isBody As String, Optional isFile As String = "NONE") As Boolean
        '   isMode = izymailer_Draft, izymailer_Display, or izymailer_Send
        '   isTo     the recipient's mail address
        '   isSubj   the mail subject
        '   isBody   the mail body text
        '   isFile   the drive:/path/name.extension of a file to attach (leave blank if no attachment)
        '   on error FALSE, else TRUE
        On Error GoTo err_izyMailer
        Dim objOutlook As Object
        Dim objOutMail As Object
        Dim objOutFile As Object
        Set objOutlook = CreateObject("Outlook.Application")
        Set objOutMail = objOutlook.CreateItem(imCstOLMailItem)
        Set objOutFile = objOutMail.Attachments
        With objOutMail
            .Subject = isSubj
            .Body = isBody
            .To = isTo
        End With
        If Not isFile = "NONE" Then
            Set objOutFile = objOutMail.Attachments
            objOutFile.Add isFile
        End If
        If isMode = izymailer_Display Then
            objOutMail.Save                                         'save as draft
            If isMode = izymailer_Send Then objOutMail.Send         'and possibly send
        End If
        izyMailer = True                                            'success return
        On Error Resume Next
        Set objOutFile = Nothing					'tidy
        Set objOutMail = Nothing					'up
        Set objOutlook = Nothing					'objects
        Exit Function                               		'and exit
        izyMailer = False                           		'failure return
        MsgBox Err.Description, vbCritical, "izyMailer Error"
        Resume exit_izyMailer
    End Function
    EDIT: just tried it in Office 2013 - it still works
    Last edited by izyrider; 01-01-14 at 06:32.
    currently using SS 2008R2

Posting Permissions

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