|
-
Apr 5th, 2006, 07:29 PM
#1
Thread Starter
Hyperactive Member
Mail from VB6 without MAPI
There are many ways to sent email from VB, and while it is quite possible to do it with the MAPI control, i found a much simpler way, using a webbrowser control and an ASP page. My code simply retrieves the to, from, subject and body information from the url. To use it, you just create an invisble web browser in the form, and then with a little string manipulation, you can navigate to the webbrowser with all the info necessary to send the email.
The page is on my site at www.startingqbasic.co.uk/aspmailer.asp.
To use it, add values for to=,from=,subject= and body= values to the url and there you go. I use this vb code:
VB Code:
Private Sub sendmailbutton_Click()
Dim mailurl As String
mailurl = "http://www.startingqbasic.co.uk/aspmailer.asp?"
' that line sets the start of the page string
mailurl = mailurl + "to=" + to_box.Text
'this adds the to details to the navigation string
mailurl = mailurl + "&" + "from=" + from_box.Text
'this adds the from details to the navigation string
mailurl = mailurl + "&" + "subject=" + subject_box.Text
'this adds the subject details to the navigation string
mailurl = mailurl + "&" + "body=" + body_box.Text
'this adds the subject details to the navigation string
mailbrowser.Navigate (mailurl)
'this navigates the webbrowser to the page
End Sub
And thats it. It's free, and if you would like the asp code for it, just email and ask.
KAZAR
-
Apr 7th, 2006, 07:00 PM
#2
Frenzied Member
Re: Mail from VB6 without MAPI
Thank u for this nice code. I am new to vb world. could u tell me how many text boxes do i need and what should i name them in order collect email ,subject ,... and submit button. I be happy if u help me out here.Furthermore, i be happy if u share the asp code with use.Thanks
-
Apr 7th, 2006, 07:52 PM
#3
Thread Starter
Hyperactive Member
Re: Mail from VB6 without MAPI
well, the asp code i use is:
Code:
<%
Dim tovar,fromvar,subjectvar,bodyvar,Mail
Set Mail=Server.CreateObject("CDONTS.NewMail")
tovar=request.querystring("to")
fromvar=request.querystring("from")
subjectvar=request.querystring("subject")
bodyvar=request.querystring("body")
Mail.To=tovar
Mail.From=fromvar
Mail.Subject=subjectvar
Mail.Body=bodyvar
Mail.Send
Set Mail=nothing
%>
Text boxes in vb can be called anything you like, as long as you insert their text at the right point in the url.
If you looked at the end url, it would look like:
http://www.startingqbasic.co.uk/[email protected]&[email protected]&subject=ASP Mailer&body=ASP Mailer Test
or something like that
if you want to use it in a web page, then just name the textboxes to, from, subject and body, and use the get method, not the post.
I hope that answers your question
-
Apr 8th, 2006, 10:09 AM
#4
Re: Mail from VB6 without MAPI
you could use the INet control also
-
Apr 8th, 2006, 11:38 AM
#5
Thread Starter
Hyperactive Member
Re: Mail from VB6 without MAPI
True, but it doesn't differ functionality.
You could have a sub that did this:
VB Code:
Sub sendmail()
Dim MailInet as INet
Dim mailurl As String
mailurl = "http://www.startingqbasic.co.uk/aspmailer.asp?"
' that line sets the start of the page string
mailurl = mailurl + "to=" + to_box.Text
'this adds the to details to the navigation string
mailurl = mailurl + "&" + "from=" + from_box.Text
'this adds the from details to the navigation string
mailurl = mailurl + "&" + "subject=" + subject_box.Text
'this adds the subject details to the navigation string
mailurl = mailurl + "&" + "body=" + body_box.Text
'this adds the body details to the navigation string
MailInet.OpenURL(mailurl)
'this opens the page with the dimmed inet control
End sub
That way you could just use it without having to create the INet Control First.
I must point out however that I have found computers with the Inet Control Missing for whatever reason, not so with the webbrowser control.
-
Apr 8th, 2006, 12:09 PM
#6
Thread Starter
Hyperactive Member
Re: Mail from VB6 without MAPI
Actually i have just been checking the inet control and it does work better.
The effect is the same, but, if you are looping the function, ie, sending lots of emails at once, then you have to make your program wait if you use the webbrowser control, not so with the INet.
So kudos and thanks to the182guy
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
Jul 8th, 2006, 02:07 PM
#7
Re: Mail from VB6 without MAPI
This is genius
-
Jul 9th, 2006, 07:16 AM
#8
Member
Re: Mail from VB6 without MAPI
gooooooooooooooood maaaaaaaaaaaan
-
Jul 9th, 2006, 11:43 AM
#9
Thread Starter
Hyperactive Member
Re: Mail from VB6 without MAPI
thanks, tho this is a fairly old post. i still use this method tho.
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
Jul 9th, 2006, 09:18 PM
#10
New Member
Re: Mail from VB6 without MAPI
I want to send mail by VB6, but It have to use content of my programe and auto send after. can i help you?
-
Jul 10th, 2006, 04:54 AM
#11
Thread Starter
Hyperactive Member
Re: Mail from VB6 without MAPI
You have to use code like this:
VB Code:
Option Explicit
'''''''''''Notes on this sub'''''''''''
'At the moment you may only send text based data for the body argument, but eventually i will
'add a function to send HTML.
'
'The good thing about the inet control is that it hangs the thread until it has
'finished, which makes it ideal for looping.
'''''''''''''''''''''''''''''''''''''''
Sub SendMail(to_addr As String, from_addr As String, subject As String, data As String)
Dim MailInet As INet
Dim mailurl As String
mailurl = "http://www.startingqbasic.co.uk/aspmailer.asp?"
' that line sets the start of the page string
mailurl = mailurl + "to=" + to_addr
'this adds the to details to the navigation string
mailurl = mailurl + "&" + "from=" + from_addr
'this adds the from details to the navigation string
mailurl = mailurl + "&" + "subject=" + subject
'this adds the subject details to the navigation string
mailurl = mailurl + "&" + "body=" + data
'this adds the body details to the navigation string
MailInet.OpenURL (mailurl)
'this opens the page with the dimmed inet control
End Sub
Sub SendAllData()
'Lets say you have 4 listboxes - one containing the to email addresses, another one the
'from email addresses, another one the subject and one more, with the data you wish to send
Dim i As Integer
For i = 0 To to_listbox.ListCount - 1
SendMail to_listbox.List(i), from_listbox.List(i), subject_listbox.List(i), data_listbox.List(i)
Next i
'so, for each item in the listboxes (assuming the same number in each), then all the data in the listboxes
'will be sent to the corresponding addresses.
'note, there is a limit on how much data can be sent. the advanced ones among you know that you can post data
'using winsock headers. soon i will add a post function as well, which means that there is no limit
End Sub
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
Jul 15th, 2006, 08:03 AM
#12
New Member
Re: Mail from VB6 without MAPI
Thanks a lot ~-=~-= KAZAR =-~=-~
-
Jul 24th, 2006, 08:08 PM
#13
Lively Member
Re: Mail from VB6 without MAPI
I know this is preety old
but how would one use the asp page >>?
I mean where do I put it in my server!!??
Code:
<%
Dim tovar,fromvar,subjectvar,bodyvar,Mail
Set Mail=Server.CreateObject("CDONTS.NewMail")
tovar=request.querystring("to")
fromvar=request.querystring("from")
subjectvar=request.querystring("subject")
bodyvar=request.querystring("body")
Mail.To=tovar
Mail.From=fromvar
Mail.Subject=subjectvar
Mail.Body=bodyvar
Mail.Send
Set Mail=nothing
%>
Last edited by x2fusion; Jul 24th, 2006 at 08:38 PM.
-
Jul 29th, 2006, 07:25 PM
#14
Lively Member
Re: Mail from VB6 without MAPI
Hello I been waiting days now /
Anyways I learn my host don't support ASP .. Or SMTP on my plan anyways ..
So any ideas on how to do it in PHP 4.x.x & So it don't need the local SMTP .. So it can remote ..
O yes the mail() is disabled as well in PHP lol
I want it so its like that below .. I mean so u can use it in VB still !!!
Okays
-
Jul 30th, 2006, 02:37 AM
#15
Thread Starter
Hyperactive Member
Re: Mail from VB6 without MAPI
Well, sorry for the lack of reply, but i have been on holiday.
If you want to send the email from vb then you don't need to put it on your server. Just use my server's url. To use it online, then i shall add a thing so that you can attach a url to forward to after completing the mail send. Anyway, what kind of crap server doesn't have ASP, or php mailing on it?
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
Jul 30th, 2006, 05:16 AM
#16
Lively Member
Re: Mail from VB6 without MAPI
My host is http://awardspace.com }~
& I'm on the free plan so I don't get the Mail() PHP funtion Or SMTP ..
O an there still in beta so they don't support ASP yet I guess .
& thx
-
Aug 8th, 2006, 11:33 PM
#17
Lively Member
Re: Mail from VB6 without MAPI
Hello you need to fix this lol .
http://www.startingqbasic.co.uk/aspmailer.asp
Code:
Microsoft VBScript compilation error '800a03f2'
Expected identifier
/aspmailer.asp, line 42
Upload.
-------^
-
Aug 9th, 2006, 11:33 AM
#18
Thread Starter
Hyperactive Member
Re: Mail from VB6 without MAPI
sorry i was working on it. it's fixed
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
Aug 9th, 2006, 11:39 AM
#19
Lively Member
Re: Mail from VB6 without MAPI
-
Aug 9th, 2006, 11:40 AM
#20
Thread Starter
Hyperactive Member
Re: Mail from VB6 without MAPI
Nothing, but i had updated it, but had missed something
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
Aug 9th, 2006, 11:58 AM
#21
Lively Member
Re: Mail from VB6 without MAPI
Ohh . What you update >
?
-
Aug 9th, 2006, 12:21 PM
#22
Thread Starter
Hyperactive Member
Re: Mail from VB6 without MAPI
I was adding an attachment function, but it isn't finished yet. Still got some bugs to iron out.
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
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
|