HI, hoping someone has something relatively simple, or can direct me to the right place, I want to open Outlook email
application on click and attach a document (I have the full file path and file extension)
To date I've only ever used Docmd.sendobject , can I use this to send a document. My db isnt using actual attachments, I am
just storing filepaths in a table. I guess then, next question is do I need to save the original document to the database
first as some sort of temporary attachment perhaps?
I'm not interested in actually sending the email, or closing the app after, just to open if not already, add to: & subject:
and attach a doc.
- - - - - - -
I've tracked down some code from the forums but I get error "user type not defined " on first line ... Dim Myoutlook as
not a very good start I know, I am however using access 07 in case this is anything to do with, any help much appreciated
>> NOW FIXED ! -- In VBA tools, references menu I didnt have Microsoft Outlook 12.0 Object Library set, just checked the box
and now all working fine! Code insert...
Public Function Email_now()
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim objOutlook As Object
Dim Attach As String
'Check if outlook if open
Set objOutlook = GetObject(, "Outlook.Application")
On Error GoTo 0
If objOutlook Is Nothing Then
' Enter code to open outlook...
'still working on this !!
' Now, we open Outlook for our own device..
Set MyOutlook = New Outlook.Application
' This creates the e-mail
Set MyMail = MyOutlook.CreateItem(olMailItem)
' This addresses it
MyMail.To = "test" '**put in reference to form
'MyMail.CC = MailList("Copy To")
'This gives it a subject
MyMail.Subject = "test" '**put in reference for subject
'This gives it the body
MyMail.Body = "test"
'If you want to send an attachment
'uncomment the following line
Attach = "C:usershome_steventest.txt" '** add file path to attach doc
'This sends it!
'To Display instead of Send, Uncomment the next line
'And comment the "MyMail.Send" line above this.
'Cleanup after ourselves
Set MyMail = Nothing
'Uncomment the next line if you want Outlook to shut down when its done.
'Otherwise, it will stay running.
Set MyOutlook = Nothing