Hi
I don't think it is possible to do what I want to do but here goes anyway:
I use the following code to create an e-mail from Access:
The code leaves the e-mail open for editing if required. What I want to do is save the e-mail automatically after it's sent and after any editing to the folder as specified in Forms![form1]![docfolder].
I appreciate it would be easy to automatically save the e-mail as soon as it is created by the above code, but any editing would not be saved.
Any ideas how this could be done would be greatly appreciated.
AL
I don't think it is possible to do what I want to do but here goes anyway:
I use the following code to create an e-mail from Access:
Code:
Private Sub DREmail()
If IsNull(Forms![form1]![Response Due By]) = True Then GoTo norespdate
Rem On Error GoTo nofiles
Dim strbody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim MailTo As String
Dim attnameDR As String
Dim fso As Object 'Scripting.FileSystemObject
Dim ts As Object 'Scripting.TextStream
Dim strSignFile As String
strSignFile = "C:\Signatures\untitled.htm"
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.Opentextfile(strSignFile, 1) 'ForReading
readsignature = ts.ReadAll
ts.Close
Set ts = Nothing
Set fso = Nothing
attnameDR = Forms![form1]![docfolder] & "\" & Forms![form1]![Job] & " Draft Report.doc"
'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
MailTo = Forms![form1]![Contact]
strbody = strbody & Chr(13) & Chr(10)
strbody = strbody & "<p><FONT face=Tahoma><font size=2>" & Forms![form1]![ManagerFirstName] & "</p>"
strbody = strbody & "<p>As discussed please find attached the Draft Report for the <b>" & Forms![form1]!Job & "</b> audit completed by " & Forms![form1]!AuditorName & ". I would appreciate it if you could complete the Action Plan at Appendix 1 of the Draft Report and return it to me by <b>" & Forms![form1]![respdueby] & "</b>.</p>"
strbody = strbody & "<p>I would like to thank you and your staff for the help and co-operation received during the audit.</p>"
strbody = strbody & "<p>If you require any further information, please contact us.</p>"
strbody = strbody & "<p>Regards</p>"
strbody = strbody & readsignature
'***creates email
With objEmail
.To = Forms("form1").Controls("Contact").Value
.CC = Forms("form1").Controls("empname").Value
.Subject = "Draft Internal Audit Report - " & Forms![form1]!Job
.BodyFormat = olFormatHTML
.htmlBody = strbody
.Importance = olImportanceHigh
.ReadReceiptRequested = True
.Attachments.Add attnameDR
.Display
Rem .SaveAs Forms("form1").Controls("docfolder").Value & "\Email - Draft Report.htm", olHTML
End With
Set objEmail = Nothing
Exit Sub
nofiles:
MsgBox "Draft Report is not present", vbInformation, "Cannot create e-mail"
Exit Sub
norespdate:
MsgBox "Response Due By not completed.", vbInformation, "Cannot create e-mail"
Exit Sub
End Sub
The code leaves the e-mail open for editing if required. What I want to do is save the e-mail automatically after it's sent and after any editing to the folder as specified in Forms![form1]![docfolder].
I appreciate it would be easy to automatically save the e-mail as soon as it is created by the above code, but any editing would not be saved.
Any ideas how this could be done would be greatly appreciated.
AL