diarmaidbrown
New member
- Local time
- Today, 19:57
- Joined
- Jul 8, 2011
- Messages
- 8
Hey again thanks for all the help so far you guys have been great.
Im using recordset to place data in the body of an email problem im facing i cant get each record on a new line in the email body,
The code i have done is
Private Sub Command29_Click()
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim Sttext As String
Dim sSQL As String
Dim BSN As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim Bookings As String
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set db = CurrentDb
strSQL = "SELECT Dates.DateofBooking, Dates.TypeofBooking, Dates.NumberinGroup, Dates.ActivityStartTime, Dates.ActivityEndTime FROM Dates WHERE Dates.BSN = 1;"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
Do Until Recordset.EOF
Bookings = "Booking Date: " & rs.Fields("DateofBooking").Value & "Activity: " & rs.Fields("TypeofBooking").Value & "Number in Group " & rs.Fields("NumberinGroup").Value
Recordset.MoveNext
Bookings = "Booking Date: " & rs.Fields("DateofBooking").Value & "Activity: " & rs.Fields("TypeofBooking").Value & "Number in Group " & rs.Fields("NumberinGroup").Value
Loop
' Clean Up and go home.
Set rs = Nothing
Set db = Nothing
With MailOutLook
.BodyFormat = olFormatHTML
.To = Me.EmailAddress
.Subject = "Hi"
.Body = "Please Confirm the details below are correct" & vbCrLf & _
"Your Booking REference number is:" & Me.BSN & vbCrLf & _
"Address: " & Me.Address & vbCrLf & _
"Town" & Me.Town & vbCrLf & _
"Contact Number: " & Me.Telephone & vbCrLf & _
Bookings & vbCrLf & _
"Extra Comments: " & ExtraComments & vbCrLf & vbCrLf & "Booking Taken By: " & BookenTakenBy & vbCrLf & vbCrLf & "This is an automated message. Please do not respond to this e-mail."
.Send
End With
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub
Any advice to point me in the right direction is welcome no matter how trival you think it might be as "i think i need a bigger boat"
Im using recordset to place data in the body of an email problem im facing i cant get each record on a new line in the email body,
The code i have done is
Private Sub Command29_Click()
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim Sttext As String
Dim sSQL As String
Dim BSN As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim Bookings As String
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set db = CurrentDb
strSQL = "SELECT Dates.DateofBooking, Dates.TypeofBooking, Dates.NumberinGroup, Dates.ActivityStartTime, Dates.ActivityEndTime FROM Dates WHERE Dates.BSN = 1;"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
Do Until Recordset.EOF
Bookings = "Booking Date: " & rs.Fields("DateofBooking").Value & "Activity: " & rs.Fields("TypeofBooking").Value & "Number in Group " & rs.Fields("NumberinGroup").Value
Recordset.MoveNext
Bookings = "Booking Date: " & rs.Fields("DateofBooking").Value & "Activity: " & rs.Fields("TypeofBooking").Value & "Number in Group " & rs.Fields("NumberinGroup").Value
Loop
' Clean Up and go home.
Set rs = Nothing
Set db = Nothing
With MailOutLook
.BodyFormat = olFormatHTML
.To = Me.EmailAddress
.Subject = "Hi"
.Body = "Please Confirm the details below are correct" & vbCrLf & _
"Your Booking REference number is:" & Me.BSN & vbCrLf & _
"Address: " & Me.Address & vbCrLf & _
"Town" & Me.Town & vbCrLf & _
"Contact Number: " & Me.Telephone & vbCrLf & _
Bookings & vbCrLf & _
"Extra Comments: " & ExtraComments & vbCrLf & vbCrLf & "Booking Taken By: " & BookenTakenBy & vbCrLf & vbCrLf & "This is an automated message. Please do not respond to this e-mail."
.Send
End With
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
End Sub
Any advice to point me in the right direction is welcome no matter how trival you think it might be as "i think i need a bigger boat"