lookforsmt
Registered User.
- Local time
- Today, 21:21
- Joined
- Dec 26, 2011
- Messages
- 672
ok, i have done some changes and now able to send email, but it will still not show any details on the email body. Any further suggestions
.HTMLBody = "Thank you for Booking. Please find attached." & vbNewLine & vbNewLine & _
"Booking Confirmation," & vbNewLine & _
"Terms and Conditions" & vbNewLine & vbNewLine & _
"If you have any queries regarding this booking, please get in touch." & vbNewLine & vbNewLine & _
"Many thanks" & vbNewLine & vbNewLine & _
"Louise"
frm_email_1a + frm_email_5_1
Set rs = CurrentDb.OpenRecordset("Select * from Mail where Mail.Summary_chk=Yes")
Option Compare Database
Option Explicit
Private Sub cmdMail_9_3_Click()
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Dim appOutLook As Object
Dim MailOutLook As Object
Dim strMsg As String
Dim sqlString As String
Dim sqlString1 As String
Dim StrFile As String
Dim strPath As String
Dim i As Integer
Dim rowColor As String
Dim strGreeting As String
Dim strGreeting1 As String
Dim asEmail As String
Dim Yes As String
Dim rs As ADODB.Recordset
'Set rs = New ADODB.Recordset
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(0)
Set rs = CurrentDb.OpenRecordset("Select * from Mail where Mail.Summary_chk=Yes")
strGreeting = "Dear All, " & vbNewLine & vbCrLf & "Below is the summary of returns and dispatched" & vbNewLine
strPath = "E:\Test Folder1\Reports\"
sqlString = "SELECT * From q_Tab_2222"
rs.Open sqlString, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
strMsg = "<table border='1' cellpadding='3' cellspacing='3' style='border-collapse: collapse' bordercolor='#111111' width='800'>" & _
"<tr>" & _
"<td bgcolor='#7EA7CC'> <b>Entry_Date</b></td>" & _
"<td bgcolor='#7EA7CC'> <b>VIP_flag</b></td>" & _
"<td bgcolor='#7EA7CC'> <b>LocationA</b></td>" & _
"<td bgcolor='#7EA7CC'> <b>LocationB</b></td>" & _
"<td bgcolor='#7EA7CC'> <b>LocationC</b></td>" & _
"<td bgcolor='#7EA7CC'> <b>LocationD</b></td>" & _
"<td bgcolor='#7EA7CC'> <b>LocationE</b></td>" & _
"<td bgcolor='#7EA7CC'> <b>LocationF</b></td>" & _
"<td bgcolor='#7EA7CC'> <b>Total</b></td>" & _
"</tr>"
i = 0
Do While Not rs.EOF
If (i Mod 2 = 0) Then
rowColor = "<td align=center bgcolor='#FFFFFF'> "
Else
rowColor = "<td align=center bgcolor='#E1DFDF'> "
End If
strMsg = strMsg & "<tr>" & _
rowColor & Nz(rs.Fields("Entry_Date"), "") & "</td>" & _
rowColor & Nz(rs.Fields("VIP_flag"), "") & "</td>" & _
rowColor & Nz(rs.Fields("LocationA"), "") & "</td>" & _
rowColor & Nz(rs.Fields("LocationB"), "") & "</td>" & _
rowColor & Nz(rs.Fields("LocationC"), "") & "</td>" & _
rowColor & Nz(rs.Fields("LocationD"), "") & "</td>" & _
rowColor & Nz(rs.Fields("LocationE"), "") & "</td>" & _
rowColor & Nz(rs.Fields("LocationF"), "") & "</td>" & _
rowColor & Nz(rs.Fields("Total"), "") & "</td>" & _
"</tr>"
rs.MoveNext
i = i + 1
Loop
strMsg = strMsg & "</table>"
Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
'---------------------------------------------------
' With MailOutLook
With objMail
asEmail = ""
Do While Not rs.EOF
asEmail = asEmail & rs.Fields("email_ID").Value & "; "
rs.MoveNext
Loop
.To = asEmail
If asEmail = "" Then
MsgBox "NO recipients selected!!!"
Exit Sub 'Exit the sub routine.
End If
'---------------------------------------------------
With objMail
.BodyFormat = olFormatHTML
.HTMLBody = strGreeting & strMsg
'.Body = "This is the body of the message." & vbCrLf & vbCrLf
'.Recipients.Add "user1@email.com;user2@email.com"
.Subject = "Summary Report for date"
'.Send 'if you want to send it directly without displaying on screen
'.Display 'if you want to display before sending
'End With
' StrFile = Dir(strPath & "*.*")
Do While Len(StrFile) > 0
.Attachments.Add strPath & StrFile
StrFile = Dir
Loop
'.DeleteAfterSubmit = True
'.Display
.Send
End With
MsgBox "Reports have been sent", vbOKOnly
'----------------------------------------------------
Set olApp = Nothing
Set objMail = Nothing
End With
End Sub
Set rs = CurrentDb.OpenRecordset("Select * from Mail where Mail.Summary_chk=Yes")
Set rs = CurrentDb.OpenRecordset("Select * from Mail where Mail.Summary_chk= 'Yes' ")
Mail.Summary_chk=Yes
strSQL = "SELECT Mail " & _
"From [Mail] " & _
"WHERE (((Mail.Summary_chk)=Yes)"
"WHERE (((Mail.Summary_chk)=Yes)"
Dim asOpenRecordSet as STRING
asOpenRecordSet = "Select * from Mail where Mail.Summary_chk=Yes"
Set rs = CurrentDb.OpenRecordset asOpenRecordSet
Set rs = CurrentDb.OpenRecordset asOpenRecordSet
Dim asOpenRecordSet As String
asOpenRecordSet = "Select * from Mail where Mail.Summary_chk=Yes"
Dim asOpenRecordSet As String
asOpenRecordSet = "Select * from Mail where Mail.Summary_chk=Yes"
Set rs = CurrentDb.OpenRecordset(asOpenRecordSet)
i changed the code and getting the run-time error 3265, "Item not found in this collection"