Megawisdumb
Registered User.
- Local time
- Today, 04:33
- Joined
- Apr 18, 2002
- Messages
- 17
Not having much luck taking a few fields from the record displayed in my form to an email with a command button. No attachments needed, just some basic text although with a couple of data fields from the form. I did get it to pull the first record by using the following:
Function Email()
Dim db As database
Dim recSupps As DAO.recordset
Dim objOutlook As New Outlook.Application
Dim objMessage As MailItem
Dim strOrder As String
Set db = CurrentDb()
Set recSupps = db.OpenRecordset("qryOpen")
' add a greeting to the order
strOrder = "Dear " & recSupps("Username") & _
vbCrLf & vbCrLf & _
"The following ticket was logged with the Help Desk on:" & recSupps("Autointime") & _
vbCrLf & vbCrLf & _
recSupps("Detail") & _
vbCrLf & vbCrLf & _
"TICKET STATUS: CLOSED on xx/xx/02" & _
vbCrLf & vbCrLf & _
"If you find the issue is still unresolved, please let me know" & _
vbCrLf & vbCrLf & _
"Phil"
' now create the mail message to the supplier
Set objMessage = objOutlook.CreateItem(olMailItem)
With objMessage
.Subject = "Help Ticket #1" & recSupps("Id")
.Body = strOrder
.Display
End With
' tidy up
recSupps.Close
Set recSupps = Nothing
Set objOutlook = Nothing
Set objMessage = Nothing
End Function
Function Email()
Dim db As database
Dim recSupps As DAO.recordset
Dim objOutlook As New Outlook.Application
Dim objMessage As MailItem
Dim strOrder As String
Set db = CurrentDb()
Set recSupps = db.OpenRecordset("qryOpen")
' add a greeting to the order
strOrder = "Dear " & recSupps("Username") & _
vbCrLf & vbCrLf & _
"The following ticket was logged with the Help Desk on:" & recSupps("Autointime") & _
vbCrLf & vbCrLf & _
recSupps("Detail") & _
vbCrLf & vbCrLf & _
"TICKET STATUS: CLOSED on xx/xx/02" & _
vbCrLf & vbCrLf & _
"If you find the issue is still unresolved, please let me know" & _
vbCrLf & vbCrLf & _
"Phil"
' now create the mail message to the supplier
Set objMessage = objOutlook.CreateItem(olMailItem)
With objMessage
.Subject = "Help Ticket #1" & recSupps("Id")
.Body = strOrder
.Display
End With
' tidy up
recSupps.Close
Set recSupps = Nothing
Set objOutlook = Nothing
Set objMessage = Nothing
End Function