I need to know how to email with VB. I have been all over the internet looking for codes and have found some but I can't get them to work. Does anyone have suggestions. I would like it to be able to open a default email client off of a computer and insert the email address in the proper spot, then either make an attachment or paste info from excel into the body of the email. Here is one program that I found that I would really like to use but I can't get it to work. So if you can please either try to figure this out or give me other suggestions.
Declarations:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile As String, ByVal lpParameters _
As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
Actual Program:
Public Function OpenEmail(ByVal EmailAddress As String, _
Optional Subject As String, Optional Body As String) _
As Boolean
Dim lWindow As Long
Dim lRet As Long
Dim sParams As String
sParams = EmailAddress
If LCase(Left(sParams, 7)) <> "mailto:" Then _
sParams = "mailto:" & sParams
If Subject <> "" Then sParams = sParams & "?subject=" & Subject
If Body <> "" Then
sParams = sParams & IIf(Subject = "", "?", "&"
sParams = sParams & "body=" & Body
End If
lRet = ShellExecute(lWindow, "open", sParams, _
vbNullString, vbNullString, SW_SHOW)
OpenEmail = lRet = 0
End Function
sub send_email()
OpenEmail "feedback@freevbcode.com", "Hello", "We really like your web site."
end sub
I got this code from here:
Thanks
Bob If you, or you know someone that provides daycare, (such as the person running your childs daycare), have them go to This is a software for in-home child care providers that will help them greatly
Declarations:
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile As String, ByVal lpParameters _
As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5
Actual Program:
Public Function OpenEmail(ByVal EmailAddress As String, _
Optional Subject As String, Optional Body As String) _
As Boolean
Dim lWindow As Long
Dim lRet As Long
Dim sParams As String
sParams = EmailAddress
If LCase(Left(sParams, 7)) <> "mailto:" Then _
sParams = "mailto:" & sParams
If Subject <> "" Then sParams = sParams & "?subject=" & Subject
If Body <> "" Then
sParams = sParams & IIf(Subject = "", "?", "&"
sParams = sParams & "body=" & Body
End If
lRet = ShellExecute(lWindow, "open", sParams, _
vbNullString, vbNullString, SW_SHOW)
OpenEmail = lRet = 0
End Function
sub send_email()
OpenEmail "feedback@freevbcode.com", "Hello", "We really like your web site."
end sub
I got this code from here:
Thanks
Bob If you, or you know someone that provides daycare, (such as the person running your childs daycare), have them go to This is a software for in-home child care providers that will help them greatly