|
-
Oct 27th, 2000, 06:11 AM
#1
Thread Starter
Junior Member
I want to send e-mails from my routines in VB6 but I don't know how without need to be there to press SEND button.
How can I do this with Eudora or any kind of e-mail program?
Eng. José Nogueira
Mail: [email protected]
Web: planeta.clix.pt/janogueira
Entroncamento-Santarém-PORTUGAL
-
Oct 27th, 2000, 10:30 AM
#2
You might try the ShellExecute API call. It causes the OS to launch appropriate programs based on file types/extensions.
In a regular .BAS module declare the function:
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
And in your code use something like:
Dim lngResult
lngResult = ShellExecute(Me.hwnd, "Open", "mailto:[email protected]", "", "", vbNormalFocus)
This would cause your browsers default email client to open up a new message addressed to [email protected].
If you wanted email to automatically be sent from your application (without user intervention) you'd likely need an object library for the software you wanted to send with, like using the Outlook Object Library for sending via Outlook/Exchange.
Good luck,
Paul
-
Oct 27th, 2000, 10:37 AM
#3
Frenzied Member
You can easily send a message by declaring Outlook objects. You will have to determine what/when to send. You did not indicate why you want to send an email to someone.
Do you want to notify someone when a particular event occurs? Do you want to send out regulary scheduled messages? If so, just call a procedure to send the email when the event does occur. I am doing that now with a process monitor interface. Using Outlook, I send text pages to the appropriate people when there is an event that needs immediate attention.
Try something like this:
Code:
Private Sub Auto_Send()
Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
'Create new message
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
' Set all desired Outlook properties
With objOutlookMsg
.To = "userid@users_address"
.Subject = "Automated email test"
.Body = "This is line 1" & vbNewLine
.Body = .Body & "This is line 2" & vbNewLine
.Importance = olImportanceHigh
.Send
End With
Set objOutlookMsg = Nothing
'Close Outlook instance: Important!
Set objOutlook = Nothing
MsgBox "Auto Email Complete", vbInformation
End Sub
-
Oct 30th, 2000, 05:26 AM
#4
Thread Starter
Junior Member
E-mail auto send with VB6
PWNettle as sent me an interesting code. It results but I have to little observations:
1. I can't post the Subject into the e-mails
2. It only has utility for me if it would send my e-mail automaticly because I'm not in there to click the SEND Button.
I use Eudora or Microsoft Outlook. Who can help me? I will change my e-mail browser if someone knows how to do so with another one.
My best regards
José Nogueira - PORTUGAL
Eng. José Nogueira
Mail: [email protected]
Web: planeta.clix.pt/janogueira
Entroncamento-Santarém-PORTUGAL
-
Oct 30th, 2000, 10:00 AM
#5
Um, use ccoder's example of how to use Outlook.
Paul
-
Oct 30th, 2000, 10:22 AM
#6
Fanatic Member
I think the best way to send emails is by using winsock. http://www.vbsquare.com/articles/sendmail/
-
Nov 6th, 2000, 05:41 AM
#7
Thread Starter
Junior Member
Mswinsck.ocx missing file
I'm trying the OETJE code but I can't found the Mswinsck.ocx file in my machine.
So, my VB6 compiler doesn't compile and link it.
Who can send me this missing file?
My best regards
José Nogueira
Eng. José Nogueira
Mail: [email protected]
Web: planeta.clix.pt/janogueira
Entroncamento-Santarém-PORTUGAL
-
Nov 6th, 2000, 04:01 PM
#8
Thread Starter
Junior Member
E-mailing...
The code suggested by OETJE really works. It the most useful code I ever seen since I programm in VB6.
My best regards for OETJE and for this Forum
José Nogueira
Eng. José Nogueira
Mail: [email protected]
Web: planeta.clix.pt/janogueira
Entroncamento-Santarém-PORTUGAL
-
Nov 7th, 2000, 12:54 PM
#9
Thread Starter
Junior Member
I compile and link but it doesn't work.
I tried the code OETJE noticed and it works.
However, it had not worked initialy because I had not checked the Winsock component in the object bar.
After doing that I finally compiled and linked this code.
To soon for a party...
The prelinked exe file already works, the vbp file is compilable and linkable but after that it doesn't work because it answers me "Run-time error '13': type mysmatch!". I try to do a Step by Step running and this error is concerned with the code line "ConnectToServer txtServer.Text, Winsock1", where it stops. However, sometimes my VB6 doesn't compile and tells me "Compile error: variable not defined!" pointing to "Winsock1" code of line "ConnectToServer txtServer.Text, Winsock1", the same of the last problem.
WHO CAN HELP MEEEEEEE? I'm one little step from my objective.
My best regards
José Nogueira
Eng. José Nogueira
Mail: [email protected]
Web: planeta.clix.pt/janogueira
Entroncamento-Santarém-PORTUGAL
-
Nov 7th, 2000, 04:21 PM
#10
Thread Starter
Junior Member
Please, don't forget me !!!
Please, don't forget me. Who can help me?
José Nogueira
Eng. José Nogueira
Mail: [email protected]
Web: planeta.clix.pt/janogueira
Entroncamento-Santarém-PORTUGAL
-
Sep 12th, 2007, 04:09 AM
#11
New Member
Re: How can I send automatic e-mails with VB6?
hi,
kinda new hir...
i tried the ccoder's code, i encounter an error,
"A program is trying to automatically send email on your behalf.
Do you want to allow this?
If this is unexpected, it may be a virus and you should choose 'No'.
buttons <Yes> <No> <Help>"
can it be automatically? i mean i think it should not prompt like that...
thanks,
toto
-
Sep 12th, 2007, 07:59 AM
#12
Frenzied Member
Re: How can I send automatic e-mails with VB6?
That is due to some security changes that Microsoft implemented several years ago.
You may want to consider using SMTP. Take a look at the code that I posted here.
-
Sep 13th, 2007, 07:19 AM
#13
Re: How can I send automatic e-mails with VB6?
@ccoder
i downloaded your sample from the link above, but i need to find out how to put recipient & sender address and subject, you done any of that?
ok i just found the code for that, was looking in the wrong place
Last edited by westconn1; Sep 13th, 2007 at 07:22 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 14th, 2007, 01:57 AM
#14
New Member
Re: How can I send automatic e-mails with VB6?
i tried the link that you provided...
but was not successfull in running the code, i've encountered an error stating:
"Run-time error '40006':
Wrong protocol or connection state for the requested transaction or request"
why is it like that?
but i can send email using OUTLOOK, using the same SMTP host name...
please help...
-
Sep 14th, 2007, 02:12 AM
#15
Hyperactive Member
Re: How can I send automatic e-mails with VB6?
Use Microsoft CDO. It will not prompt a messagebox if you are sending e-mails.
Rate Me! Rate Me! Rate Me!
Time to fly.
Copyright GraysonSoft Inc. 2007
-
Sep 14th, 2007, 02:21 AM
#16
New Member
Re: How can I send automatic e-mails with VB6?
hey tommy,
can you spare some codes with it?
thanks
-
Sep 14th, 2007, 03:02 AM
#17
Hyperactive Member
Re: How can I send automatic e-mails with VB6?
 Originally Posted by toto_phl
hey tommy,
can you spare some codes with it?
thanks
Have you already included the Microsoft CDO Library in your Library?
If so then hmmm........
Let me seeee........
Dang. It has been a long time since I programmed with VB 6 that I almost forgot to use CDO in VB6.
Anyway, click on this link
Last edited by tommygrayson; Sep 14th, 2007 at 03:03 AM.
Reason: Corrected posting of link.
Rate Me! Rate Me! Rate Me!
Time to fly.
Copyright GraysonSoft Inc. 2007
-
Sep 14th, 2007, 03:23 AM
#18
Re: How can I send automatic e-mails with VB6?
i was using cdo to send faxes previously, but i started getting security notification issues with it, so went to using other methods
for all you ever wanted to know about cdo, try http://www.cdolive.com/default.htm
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 14th, 2007, 03:24 AM
#19
New Member
Re: How can I send automatic e-mails with VB6?
i already added CDO in the reference...
got the source code from the link you provided...
but the part where it states the:
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ""
it said that it should use the IP address, i dunno the IP. i only know the host name...
is it the same?
-
Sep 14th, 2007, 03:28 AM
#20
Re: How can I send automatic e-mails with VB6?
Run-time error '40006':
Wrong protocol or connection state for the requested transaction or request"
this can be resolved by changing the sever address to an ip address
to get the ip address, you can ping the server address or with winsock as after connecting the connection ip address is one of its properties
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 14th, 2007, 03:35 AM
#21
New Member
Re: How can I send automatic e-mails with VB6?
what if you don't know the IP address, only the host name?
is it the same?
-
Sep 14th, 2007, 05:08 AM
#22
Hyperactive Member
Re: How can I send automatic e-mails with VB6?
 Originally Posted by toto_phl
what if you don't know the IP address, only the host name?
is it the same?
You can determine the IP address of the host name by pinging it.
You can also type the Host name instead of the IP name but it is not common practice.
Rate Me! Rate Me! Rate Me!
Time to fly.
Copyright GraysonSoft Inc. 2007
-
Sep 14th, 2007, 08:17 AM
#23
Re: How can I send automatic e-mails with VB6?
i believe winsock needs to resolve the server address to a MX server to send mail, so if the server (hostname) you connect to is an A or other server it will fail to send mail, with the error you reported before, if you connect to the ip address of the server it will look at what servers are available, at that IP, to see if there is a MX server to connect to
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 14th, 2007, 08:28 AM
#24
Frenzied Member
Re: How can I send automatic e-mails with VB6?
 Originally Posted by toto_phl
i tried the link that you provided...
but was not successfull in running the code, i've encountered an error stating:
"Run-time error '40006':
Wrong protocol or connection state for the requested transaction or request"
why is it like that?
but i can send email using OUTLOOK, using the same SMTP host name...
please help...
I can't help you until I get some more information.
Did you make any changes other than filling in the 3 pieces of information that the program needs? These would be in the lines:
Code:
sckMail.RemoteHost = "smtp server address goes here" ' supply server address
addyList = "address1@domain1;address1@domain2" ' supply address list (1 or more)
sckMail.SendData "MAIL FROM:<sender@domain>" & vbCrLf ' supply sender@domain
Where in the code is the error occurring? What have you done up to that point?
-
Sep 14th, 2007, 05:06 PM
#25
Re: How can I send automatic e-mails with VB6?
@ ccoder, i got the same error when i put our server address in the format www.????????.com.au (as it is in outlook etc)
when i put it in as an IP address it worked ok, (see my post above) as it resolved to the mail server
but the test emails i sent mostly did not arrive (out of about 10 sent to 2 email addresses only 1 arrived) so i have to look at it some more
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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
|