The code works for me. Post your entire procedure, including the SendEMail Sub.
The code works for me. Post your entire procedure, including the SendEMail Sub.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Private Sub Complete_Click()
Dim OL As Outl ook.Application
Dim MyItem As Outlook.MailItem
Dim sHTML As String
Dim sSubject As String
Dim sTo As String
Dim sCC As String
Dim sBody As String
'specifiy the references for the object library
'This is the body of the email, the "<br><br><br> are breaks for the html
'Original
'sHTML = "<html><body> Collation Team," & "<br><br><br> " & "AutoRelease priorities have been changed to the below settings." & "<br><br><br> " & "Reason" & "<br><br><br> " & _
"New Settings" & "<br><br><br> " & "" & " <br></body></html>"
sHTML = "<html><body> Collation Team," & "<br><br><br> " & "AutoRelease priorities have been changed to the below settings." & "<br><br><br> " & "Reason:" & Me.Reason & " <br><br><br> " & _
"New Settings:" & "<br><br><br> " & "<img src='C:\Users\dmcmillo\Pictures\2 alt='some text' style='width:145px;height:126px;'></body></html>" & " <br></body></html>"
sSubject = "Collation AutoRelease Priority Change"
'sTo = ""
'sCC = ""
'calls the function to email
Call SendEMail(sTo, sCC, sSubject, sHTML)
End Sub
Public Function SendEMail(sTo, sCC, sSubject, sBody)
Dim olapp As Object
'Set olapp = CreateObject("outlook.application")
Dim objMail As Object
Dim olReceipent As Object
On Error GoTo Err_Handler
Set olapp = GetObject(, "outlook.application.14")
If olapp Is Nothing Then
GoTo Err_Handler
End If
Set objMail = olapp.CreateItem(0)
With objMail
.To = sTo
.CC = sCC
.Subject = sSubject
.HTMLBody = sBody
.Display
.send
End With
Set olapp = Nothing
Set objMail = Nothing
Exit_Handler:
Exit Function
Err_Handler:
Resume Exit_Handler
End Function
Not seeing a file name in the path and need closing apostrophe: 'C:\Users\dmcmillo\Pictures\2
Should be like: 'C:\Users\dmcmillo\Pictures\2.jpg'
Or whatever file name and extension your image has. The image name can be pulled from a textbox and concatenated into the HTML code same as the Reason text.
You actually have more concatenation than necessary.
sHTML = "<html><body>Collation Team,<br><br><br>AutoRelease priorities have been changed to the below settings.<br><br><br>Reason: " & Me.Reason & "<br><br><br>" & _
"New Settings:<br><br><br><img src='C:\Users\dmcmillo\Pictures\" & Me.Image & "' alt='no image available' style='width:145px;height:126px;'></body></html><br></body></html>"
Last edited by June7; 10-21-2015 at 05:46 PM.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Thanks for responding. I tried adding the full filepath as you stated. that didn't work. I go the same results as before.
Again, post your exact modified code.
Don't know what else to say. The code works for me. Here is mine:
Code:Private Sub Email() Dim appOutLook As Outlook.Application Dim MailOutLook As Outlook.MailItem Set appOutLook = CreateObject("Outlook.Application") Set MailOutLook = appOutLook.CreateItem(olMailItem) With MailOutLook .BodyFormat = olFormatRichText .To = "" ''.cc = "" ''.bcc = "" .Subject = "Central Materials Laboratory Data" .HTMLBody = "<html><body>Collation Team,<br><br><br>AutoRelease priorities have been changed to the below settings.<br><br><br>Reason: Test<br><br><br>" & _ "New Settings:<br><br><br><img src='C:\Users\June\DOT\Lab\Editing\LABDB.png' alt='some text' style='width:145px;height:126px;'></body></html>" .Display End With End Sub
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.