I am trying to send a report in the body of an e-mail rather then by attachment. Reason being too many complaints about the attachments; extra steps to view, looking distorted when viewed on small screens, etc..)
The following are two codes I have modified to use however I get errors on both of them. The top code sends false or 0 in the body instead of the data. And the second either gives me an error on the .Send line, but if I remove it clicking the button does nothing.
I have been searching the threads for awhile and I know this is possible but I have not been able to find the answer that helps me yet.:banghead:
The following are two codes I have modified to use however I get errors on both of them. The top code sends false or 0 in the body instead of the data. And the second either gives me an error on the .Send line, but if I remove it clicking the button does nothing.
Code:
Private Sub Email_Click()
Dim olApp As Object
Dim olMail As Object
Dim StMailBody As String
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0)
With olMail
.To = ""
.Subject = ([ProductionOrProcessing] & " Shift Report " & [ID])
.HtmlBody = .HtmlBody = "<html>Safety" < br > Me.Safety < br > "Quality: &< br > Me.Quality</html>"
.Display
End With
Set olMail = Nothing
Set olApp = Nothing
End Sub
Code:
Private Sub Email2_Click()
Dim mess_body As String
Dim olApp As Object
Dim olMail As Object
Dim StMailBody As String
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
StMailBody = StMailBody = "Safety" < br > Me.Safety < br > "Quality: " < br > Me.Quality
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.To = ""
.Subject = ([ProductionOrProcessing] & " Shift Report " & [ID])
.Body = StMailBody
.Send = ""
End With
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
Resume Error_out
Error_out:
Set olMail = Nothing
Set olApp = Nothing
End Sub
I have been searching the threads for awhile and I know this is possible but I have not been able to find the answer that helps me yet.:banghead: