Hi everybody,
I want to send an email to multi users through my VB application.
How do I do that? (my email account is gmail.)
Thank you
Tova
Printable View
Hi everybody,
I want to send an email to multi users through my VB application.
How do I do that? (my email account is gmail.)
Thank you
Tova
What version of VB?
-tg
Vb 6.0
In that case your thread would be better in our "VB6" forum (as there is no particular reason to use API's to do what you want), so I've moved the thread there.
Are you sending multiple copies or are you sending all different messages?
Different messages.
I need to send an email through my VB application.
If I find out how to send 1 email to 1 addressee that would be great.
I found several code samples on the internet, but they all lack the info how to setup the library that they use. Some mention that the library need to be purchased. I need a free option.
Is MAPI free? How do I get it, install it, make my VB app recognize it?
Thanks
Tova
check out this thread for using cdo.message with gmail
http://www.vbforums.com/showthread.p....message+gmail
I get: Compile error: User defined type not defined
About the: CDO.Message .
How do I define it?
set a refrerence to the CDO dll. It was in the code snip: "'Add the Project Reference Miscrosoft CDO WINDOWS FOR 2000"
-tg
Excuse my ignorance, but how do I set a reference to a dll?
And is it a dll supposed to be on my computer, or be downloaded from the net?
Yes you need to have the dll and any of its dependancies.
To add a reference...
Project > References... > scroll through your list and find "Microsoft CDO for Windows 2000 Library" (cdosys.dll) > check its box > click OK. Done :)
The closest I have on that list is: Microsoft CDE for Exchange 200 library. (cdoex.dll)
Should it work?
I downloaded cdosys.dll from the net, and placed it at same folder as cdoex.dll, but that doesn't put it on the project references list.
Help.
Thanks
Tova
cdo is part of windows xp (and other) default install
try this to see if it works
this requires no references just paste in to a button or something and runvb Code:
Set omsg = CreateObject("cdo.message") MsgBox omsg.configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpaccountname") Set omsg = Nothing
the message box should give the name of your default smtp server,
you will need to change this and other settings for gmail if you want to use that
here is a complete code for gmail, using late binding, no reference required
Code:Set objmessage = CreateObject("CDO.Message")
objmessage.Subject = "Example CDO Message"
objmessage.From = "[email protected]"
objmessage.To = "me" ' sent to myself, not at gmail
objmessage.TextBody = "This is some sample message text."
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'Your UserID on the SMTP server
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "usernm"
'Your password on the SMTP server
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "pass"
'Name or IP of Remote SMTP Server
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
'Server port (typically 25)
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
'Use SSL for the connection (False or True)
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
objmessage.Configuration.Fields.Update
objmessage.Send
Set objmessage = Nothing
The MsgBox displays nothing but the OK button.
I tried it works...
that means no default stmp sever, but if you got no error then an object of CDO must have been created so if you use the code posted it should send email via gmailQuote:
The MsgBox displays nothing but the OK button.
Thanks! It works!
But it only sends 128 emails and then fails.
Could you let me know please, because I don't really have a way to check it myself:
How much time do I need to wait between 128 email-sends to the next 128?
And If I send same email message to many addressees, is there a limit on the number of addressees?
What is the "right" way to send multiple emails?
It is a library application. (Library - aka books lending library - check in check out application.) We need the application to send emails to all members who are late in returning books. Ideally, we want the list of specific books to be enumerated in the email. Which means different text for each member. But, in case it is much easier to send uniform text to all members who are late, we will consider that. If you can answer the above Qs, we will be able to make the wise decision.
Thank you very much!
Tova
that maybe a limitation to gmail server (many servers have limits to stop spam)
try sending 120, take a break then send next 120, etc
Do you usually have 128 or more than 128 people who cross their due dates? Surprising... Sorry if I am being suspicious but I keep on seeing these kind of requests off and on...Quote:
It is a library application. (Library - aka books lending library - check in check out application.) We need the application to send emails to all members who are late in returning books. Ideally, we want the list of specific books to be enumerated in the email. Which means different text for each member. But, in case it is much easier to send uniform text to all members who are late, we will consider that. If you can answer the above Qs, we will be able to make the wise decision.
Edit: How big is your library and where is it located?
Hi
The library is located at Beit-Shemesh, Israel.
I develop the application voluntarily.
The application was copied to several smaller libraries.
I expect 128 or more than 128 people who cross their due dates, initially when the send-emails-to-members-who-are-late functionality is new. I expect the number to decrese later, due to our better ability to remind them to return the books.
Thanks!
Tova
Of course you could always use the Winsock control to send email. Might be a little hard to code but that way you could send a email with a none return address. i.e. [email protected] used to send a order to you but can't receive.
hi, sorry to bump, how would this work for a non-gmail account, i will be using my domains smtp server to send emails, and just need a really simple few lines of code to send an email on an event in a piece of software i am writing...
thanks
hi, just tried what has been said in this post, but it fails straight away, this is the code I copied, and i get a 'comiple error, variable not defined' on the first line
This is the code I have, I have initially put it on a button to test:Code:Set omsg = CreateObject("cdo.message")
Thanks in advance for any help!Code:Private Sub Command3_Click()
Set omsg = CreateObject("cdo.message")
MsgBox omsg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpaccountname")
Set omsg = Nothing
Set objmessage = CreateObject("CDO.Message")
objmessage.Subject = "Example CDO Message"
objmessage.From = "my_email_address"
objmessage.To = "my_test_email_address" ' sent to myself, not at gmail
objmessage.TextBody = "This is some sample message text."
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'Your UserID on the SMTP server
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "my_email_address"
'Your password on the SMTP server
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypass"
'Name or IP of Remote SMTP Server
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.gavinwatson.com"
'Server port (typically 25)
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
'Use SSL for the connection (False or True)
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objmessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
objmessage.Configuration.Fields.Update
objmessage.Send
Set objmessage = Nothing
End Sub
i presume you smtp would be using port 25
and not requiring ssl (smtpusessl)
try changing those
local (isp) smtp servers often will work with the default configuration (no need to change any configuration fields)
But would that give me a variable not defined error?
And yes, 25 and no ssl
The error "Variable not defined" means that you are trying to use a variable that has not been declared (a Dim line).
In this case you should use the data type Object, so:
Code:Dim omsg as Object
aha! of course, sorry, and thanks!
now i get this:
runtime error -2147220973 (80040213)
the transport failed to connect to the server
that means what ever credentials you are using to logon to the SMTP server isn't correct. Could be a bad password, bad user name, or something like that.
-tg
SPot on!
Many thanks!