How to send Email with attachments in VB

hi EE.
I want to send email with or without attachments from withing my VB application.
I don't want to use outlook. when user presses send information then my application itself able to send email silently.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There are a lot of manners to send email from vb
1) Perhaps the easiest way:
2) You can also try with shellexecute

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

Sub SendMail(ByVal strAddress As String, _
Optional ByVal strCC As String, _
Optional ByVal strBCC As String, _
Optional ByVal strSubject As String, _
Optional ByVal strBodyText As String)
   Dim strTemp As String
   If Trim(Len(strCC)) Then
   strTemp = "&CC=" & strCC
   End If
   If Trim(Len(strBCC)) Then
   strTemp = strTemp & "&BCC=" & strBCC
   End If
   If Trim(Len(strSubject)) Then
   strTemp = strTemp & "&Subject=" & strSubject
   End If
   If Trim(Len(strBodyText)) Then
   strTemp = strTemp & "&Body=" & strBodyText
   End If
   If Len(strTemp) Then
   Mid(strTemp, 1, 1) = "?"
   End If

   strTemp = "mailto:" & strAddress & strTemp
   ShellExecute 0, "open", strTemp, 0, 0, SW_NORMAL
End Sub
3) You need a reference (project - references): Microsoft outlook object library.
    This option will automatically send everything
(more info:
     Sending e-mail through outlook express:
Public Sub SendEmailViaOE(AttachememtPath As String, FromEmail As String, ToEmail As String, Subject As String)
Dim objOutlook As Outlook.NameSpace
Dim objNewMail As Outlook.MailItem
Dim testvar As Variant

Dim cd As CDO.Message
Set cd = New CDO.Message
cd.Subject = Subject
cd.To = ToEmail
cd.From = FromEmail
cd.AddAttachment AttachememtPath
cd.TextBody = "Hello this Brent"
'cd.AddRelatedBodyPart "c:\txtVes.txt", "ss", cdoRefTypeId

Set cd = Nothing
End Sub

4) ...
More Examples:
NaeemgAuthor Commented:
hello Dhaest i tried both of ur given method in form load event, but when compiles an error msg "expecting =" raised.
NaeemgAuthor Commented:
sorry i was not used Call statement to call method.
but SendMail method opens another popup to send, i don't want that,

and by using sendEmailViaOE rais an compile erro "User-defined type not defined"
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NaeemgAuthor Commented:
hello anv both of ur answers do not satisfied me.
did u download the source code avaialbale in the last link..

try it ..its good..
NaeemgAuthor Commented:
my problem is solved using CDONTS by anv.
thanks to all.
NaeemgAuthor Commented:
hi anv, would u pls give me an additional line of code to attach file.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.