|
-
May 4th, 2004, 04:02 AM
#1
Thread Starter
Member
Sending Email using VB
Hi all
Actually I have some data and I want to send it to some email id
when user clicks on the command button the data (in fact a string ) should b send to the hard coded email id.
how can I do it?
Nahush.
-
May 4th, 2004, 04:50 AM
#2
^:^...ANGEL...^:^
Open a project, put following controls.
TextBox called txtSendTo
TextBox callled txtSubject
TextBox called txtMessage
MAPIMessages called MAPIMessages1
MAPISession called MAPISession1
Commandbutton called cmdSend
-----------------------
To Add MAPI controls
-----------------------
Click on Project Menu -> Components and find Microsoft MAPI Controls and check that box and press OK.
Now you should have 2 more controls in Toolbox on the left hand side. Just add them to the form.
-----------------------
and the following code should do it.
VB Code:
Private Sub cmdSend_Click()
If Trim(txtSendTo.Text) = "" Then
MsgBox "Please enter an email address to send EMail.", vbInformation, MSGBoxTitle
Else
MAPISession1.SignOn
With MAPIMessages1
.MsgIndex = -1
.RecipDisplayName = txtSendTo.Text
.MsgSubject = txtSubject.Text
.MsgNoteText = txtMessage.Text
.SessionID = MAPISession1.SessionID
.Send
End With
MsgBox "Message sent.", vbInformation, MSGBoxTitle
MAPISession1.SignOff
End If
End Sub
Cheers
-
May 4th, 2004, 05:17 AM
#3
Thread Starter
Member
Update
the code above requires outlook express
But can be there any possibility that even if the computer with
outlook not installed should also send the msg.
i.e inspite of the outlook (or NE other mail prgm ) the mail should
be sent to the resipient
Nahush
-
May 4th, 2004, 05:32 AM
#4
^:^...ANGEL...^:^
in that case u might want to look at SMTP stuff. But unfortunately I haven't got any code for that. Sorry.
-
May 4th, 2004, 06:59 AM
#5
-
May 4th, 2004, 08:27 AM
#6
goto http://www,codehound.com/vb
in the search box, enter VBSendMail. Click Search (or GO, or what ever the button is).
Sift through the results, there's plenty of examples on this.
TG
-
Jun 27th, 2004, 02:48 AM
#7
Registered User
Hi All!!!
I M trying to send mail but a need your help.
i have microsoft outlook with one address and outlook express with another address and when i m sending ,mail it sends with the mail of the microsoft outlook and i want to send the mail with the address in the outlook express .
what should i do ?
10x
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|