Dag allen,
Ik moet in Access via een knop "Send email" ervoor zorgen dat Outlook opent, en dat de handtekening er dan automatisch in staat.
Daarvoor heb ik al veel gezocht op internet, en vond ik de onderstaande code van Ron de Bruin. Daarover heb ik een aantal vraagjes.
De functie GetBoiler, waar komt die te staan? Komt die gewoon boven de code van de button? Of staat deze apart? Als ik de code zo erin zet
en ik klik op "Send email", dan gebeurd er niks. Zie ik iets over het hoofd, of staat de code gewoon niet goed?
Ik ben niet zo'n ster hierin, dus ik hoop dat iemand mij hiermee kan helpen.
Mijn dank is groot.
Met vriendelijke groet,
Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Sub Knop160_Click()
' Don't forget to copy the function GetBoiler in the module.
' Working in Office 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim SigString As String
Dim Signature As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<H3><B>Dear Customer</B></H3>" & _
"Please visit this website to download the new version.<br>" & _
"Let me know if you have problems.<br>" & _
"<A HREF=""http://www.rondebruin.nl/tips.htm"">Ron's Excel Page</A>" & _
"<br><br><B>Thank you</B>"
'Use the second SigString if you use Vista or win 7 as operating system
SigString = "C:\Users\gebruikersnaam\AppData\Roaming\Microsoft\Templates\Tester.oft"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
On Error Resume Next
With OutMail
.To = "eigen emailadres"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = strbody & "<br><br>" & Signature
'You can add files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Ik moet in Access via een knop "Send email" ervoor zorgen dat Outlook opent, en dat de handtekening er dan automatisch in staat.
Daarvoor heb ik al veel gezocht op internet, en vond ik de onderstaande code van Ron de Bruin. Daarover heb ik een aantal vraagjes.
De functie GetBoiler, waar komt die te staan? Komt die gewoon boven de code van de button? Of staat deze apart? Als ik de code zo erin zet
en ik klik op "Send email", dan gebeurd er niks. Zie ik iets over het hoofd, of staat de code gewoon niet goed?
Ik ben niet zo'n ster hierin, dus ik hoop dat iemand mij hiermee kan helpen.
Mijn dank is groot.
Met vriendelijke groet,
Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Sub Knop160_Click()
' Don't forget to copy the function GetBoiler in the module.
' Working in Office 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim SigString As String
Dim Signature As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<H3><B>Dear Customer</B></H3>" & _
"Please visit this website to download the new version.<br>" & _
"Let me know if you have problems.<br>" & _
"<A HREF=""http://www.rondebruin.nl/tips.htm"">Ron's Excel Page</A>" & _
"<br><br><B>Thank you</B>"
'Use the second SigString if you use Vista or win 7 as operating system
SigString = "C:\Users\gebruikersnaam\AppData\Roaming\Microsoft\Templates\Tester.oft"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
On Error Resume Next
With OutMail
.To = "eigen emailadres"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = strbody & "<br><br>" & Signature
'You can add files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub