Email in Body (1 Viewer)

MayaMana

Registered User.
Local time
Today, 18:43
Joined
May 29, 2012
Messages
60
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.

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:
 

boblarson

Smeghead
Local time
Today, 15:43
Joined
Jan 12, 2001
Messages
32,059
Your first one would be the way to go but you have not included the <br> stuff inside the quotes where it needs to be and the rest of the html tags.

So this:
.HtmlBody = .HtmlBody = "<html>Safety" < br > Me.Safety < br > "Quality: &< br > Me.Quality</html>"
.Display


Should be this:

.HtmlBody = "<html><body>Safety<br> " & Me.Safety & " <br> Quality: <br> " & Me.Quality & " </body></html>"
.Display
 

MayaMana

Registered User.
Local time
Today, 18:43
Joined
May 29, 2012
Messages
60
Thank you so much! I knew it had to be something little.
 
Last edited:

Users who are viewing this thread

Top Bottom