|
-
Aug 19th, 2009, 01:16 PM
#1
Thread Starter
Junior Member
[RESOLVED] Send email through VB?
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
-
Aug 19th, 2009, 01:19 PM
#2
Re: Send email through VB?
-
Aug 19th, 2009, 01:59 PM
#3
Thread Starter
Junior Member
Re: Send email through VB?
-
Aug 19th, 2009, 02:10 PM
#4
Re: Send email through VB?
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.
-
Aug 19th, 2009, 05:21 PM
#5
Re: Send email through VB?
Are you sending multiple copies or are you sending all different messages?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 20th, 2009, 03:26 AM
#6
Thread Starter
Junior Member
Re: Send email through VB?
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
-
Aug 20th, 2009, 05:24 AM
#7
Re: Send email through VB?
check out this thread for using cdo.message with gmail
http://www.vbforums.com/showthread.p....message+gmail
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
-
Aug 20th, 2009, 08:06 AM
#8
Thread Starter
Junior Member
Re: Send email through VB?
I get: Compile error: User defined type not defined
About the: CDO.Message .
How do I define it?
-
Aug 20th, 2009, 08:29 AM
#9
Re: Send email through VB?
set a refrerence to the CDO dll. It was in the code snip: "'Add the Project Reference Miscrosoft CDO WINDOWS FOR 2000"
-tg
-
Aug 20th, 2009, 08:33 AM
#10
Thread Starter
Junior Member
Re: Send email through VB?
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?
-
Aug 20th, 2009, 02:01 PM
#11
Re: Send email through VB?
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 20th, 2009, 03:51 PM
#12
Thread Starter
Junior Member
Re: Send email through VB?
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
-
Aug 21st, 2009, 02:59 AM
#13
Re: Send email through VB?
cdo is part of windows xp (and other) default install
try this to see if it works
vb Code:
Set omsg = CreateObject("cdo.message") MsgBox omsg.configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpaccountname") Set omsg = Nothing
this requires no references just paste in to a button or something and run
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
Last edited by westconn1; Aug 21st, 2009 at 03:08 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
-
Aug 22nd, 2009, 02:27 PM
#14
Thread Starter
Junior Member
Re: Send email through VB?
The MsgBox displays nothing but the OK button.
-
Aug 22nd, 2009, 02:46 PM
#15
Hyperactive Member
Re: Send email through VB?
-
Aug 22nd, 2009, 05:23 PM
#16
Re: Send email through VB?
The MsgBox displays nothing but the OK button.
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 gmail
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
-
Aug 24th, 2009, 07:09 AM
#17
Thread Starter
Junior Member
Re: Send email through VB?
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
-
Aug 24th, 2009, 04:26 PM
#18
Re: Send email through VB?
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
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
-
Aug 24th, 2009, 05:55 PM
#19
Re: Send email through VB?
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.
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...
Edit: How big is your library and where is it located?
Last edited by Siddharth Rout; Aug 24th, 2009 at 06:00 PM.
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Aug 25th, 2009, 07:30 AM
#20
Thread Starter
Junior Member
Re: Send email through VB?
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
-
Aug 26th, 2009, 05:31 AM
#21
Member
Re: [RESOLVED] Send email through VB?
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.
-
Sep 15th, 2009, 03:40 PM
#22
Addicted Member
Re: [RESOLVED] Send email through VB?
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
-
Sep 15th, 2009, 04:05 PM
#23
Addicted Member
Re: [RESOLVED] Send email through VB?
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
Code:
Set omsg = CreateObject("cdo.message")
This is the code I have, I have initially put it on a button to test:
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
Thanks in advance for any help!
-
Sep 15th, 2009, 04:13 PM
#24
Re: [RESOLVED] Send email through VB?
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)
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 15th, 2009, 04:15 PM
#25
Addicted Member
Re: [RESOLVED] Send email through VB?
But would that give me a variable not defined error?
And yes, 25 and no ssl
-
Sep 15th, 2009, 04:27 PM
#26
Re: [RESOLVED] Send email through VB?
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:
-
Sep 15th, 2009, 04:31 PM
#27
Addicted Member
Re: [RESOLVED] Send email through VB?
aha! of course, sorry, and thanks!
now i get this:
runtime error -2147220973 (80040213)
the transport failed to connect to the server
-
Sep 15th, 2009, 04:42 PM
#28
Re: [RESOLVED] Send email through VB?
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
-
Sep 15th, 2009, 05:13 PM
#29
Addicted Member
Re: [RESOLVED] Send email through VB?
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
|