Herzalah
asked on
Sending Emails from a Desktop VB application
I have a small utility from which I want to send emails. Is there anyway to send emails from VB with WinNT and Win2000 without using any third party component. I also don't want to install IIS or SQL Server at the client machine. They have WinNT or Win2000 as O.S.
If this cannot be done, is there anyway to do that with a Free third party component?
Thanks,
Herzalah
If this cannot be done, is there anyway to do that with a Free third party component?
Thanks,
Herzalah
1. You can use MAPI or CDO.
MAPI (Messaging Application Programming Interface) A messaging architecture and a client interface component.
As a messaging architecture, MAPI enables multiple applications to interact with multiple messaging systems across a variety of hardware platforms. See also MAPI subsystem, messaging system.
As a client interface component, MAPI is the complete set of functions and object-oriented interfaces that forms the foundation for the MAPI subsystem's client application and service provider interfaces. In comparison with Simple MAPI, Common Messaging Calls (CMC), and the CDO Library, MAPI provides the highest performance and greatest degree of control to messaging-based applications and service providers.
2. There are lot of freeware components for sending emails.
http://www.aspsmart.com/ -one of them.
I don't remember URL but you can find components JMail and ASPMail yourself.
Good luck!
MAPI (Messaging Application Programming Interface) A messaging architecture and a client interface component.
As a messaging architecture, MAPI enables multiple applications to interact with multiple messaging systems across a variety of hardware platforms. See also MAPI subsystem, messaging system.
As a client interface component, MAPI is the complete set of functions and object-oriented interfaces that forms the foundation for the MAPI subsystem's client application and service provider interfaces. In comparison with Simple MAPI, Common Messaging Calls (CMC), and the CDO Library, MAPI provides the highest performance and greatest degree of control to messaging-based applications and service providers.
2. There are lot of freeware components for sending emails.
http://www.aspsmart.com/ -one of them.
I don't remember URL but you can find components JMail and ASPMail yourself.
Good luck!
You could look at this question (still open):
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20122015
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20122015
Here's some code I use to send email automaticlly with Outlook using MAPI.
I have a table in my database called EmailNotification that contains the names and addresses of recipients.
fields(0) is their name and
fields(1) is their address in the table.
Place a MAPISession control on the form and call it MAPISession1
Place a MAPIMessages control on the form and call it mail.
Private Sub send_mail()
Dim x as Integer
dtaEmail.RecordSource = "select * from [EmailNotification]"
dtaEmail.Refresh
dtaEmail.Recordset.MoveLas t
dtaEmail.Recordset.MoveFir st
strEmailMessage = "This is a test message"
For X = 0 To dtaEmail.Recordset.RecordC ount - 1
strMailName = dtaEmail.Recordset.Fields( 0)
strEmailName = dtaEmail.Recordset.Fields( 1)
MAPISession1.LogonUI = False
MAPISession1.UserName = "MICROSOFT OUTLOOK"
MAPISession1.SignOn
mail.SessionID = MAPISession1.SessionID
mail.Compose
mail.RecipDisplayName = strMailName
mail.RecipAddress = strEmailName
mail.ResolveName
mail.MsgSubject = "Test message!"
'Create the message
mail.MsgNoteText = strEmailMessage
mail.Send False
MAPISession1.SignOff
dtaEmail.Recordset.MoveNex t
next
end sub
Later...
I have a table in my database called EmailNotification that contains the names and addresses of recipients.
fields(0) is their name and
fields(1) is their address in the table.
Place a MAPISession control on the form and call it MAPISession1
Place a MAPIMessages control on the form and call it mail.
Private Sub send_mail()
Dim x as Integer
dtaEmail.RecordSource = "select * from [EmailNotification]"
dtaEmail.Refresh
dtaEmail.Recordset.MoveLas
dtaEmail.Recordset.MoveFir
strEmailMessage = "This is a test message"
For X = 0 To dtaEmail.Recordset.RecordC
strMailName = dtaEmail.Recordset.Fields(
strEmailName = dtaEmail.Recordset.Fields(
MAPISession1.LogonUI = False
MAPISession1.UserName = "MICROSOFT OUTLOOK"
MAPISession1.SignOn
mail.SessionID = MAPISession1.SessionID
mail.Compose
mail.RecipDisplayName = strMailName
mail.RecipAddress = strEmailName
mail.ResolveName
mail.MsgSubject = "Test message!"
'Create the message
mail.MsgNoteText = strEmailMessage
mail.Send False
MAPISession1.SignOff
dtaEmail.Recordset.MoveNex
next
end sub
Later...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry emoreau
My first link duplicated yours :-)
My first link duplicated yours :-)
<ping>
Here it is short and sweet:
set mail = Createobject("CDONTS.newma il")
mail.To = "somebody@somewhere.com"
mail.From = "somebody@somewhere.com"
mail.Subject = "Hey"
mail.Body = "Don't you just love automation?!"
mail.Send
set mail = Createobject("CDONTS.newma
mail.To = "somebody@somewhere.com"
mail.From = "somebody@somewhere.com"
mail.Subject = "Hey"
mail.Body = "Don't you just love automation?!"
mail.Send
You should definitely use the code from TimCotee's link. Using MAPI or CDO is fine, provided the user has it installed on their machine, AND has it configured correctly. If you use the code he links to, all they need is a TCP/IP stack, which AFAIK is pretty standard (grin.)
You can still run into logistical problems with this code, namely deciding what mail sever to connect to. If this app is for use within one specific company, you can just use the company's internal e-mail server. If this app is going to be used by people from multiple domains (DNS, not NT), you may run into problems with people from ABC corp not being able to send e-mail through XYZ corp's SMTP server. This is relatively nice to try to keep spam down, but a PITA for you. You're either going to have to find a "friendly" SMTP server, ask the user to input their SMTP server's address, or find some way to automagically figure out an SMTP server to use.
You can still run into logistical problems with this code, namely deciding what mail sever to connect to. If this app is for use within one specific company, you can just use the company's internal e-mail server. If this app is going to be used by people from multiple domains (DNS, not NT), you may run into problems with people from ABC corp not being able to send e-mail through XYZ corp's SMTP server. This is relatively nice to try to keep spam down, but a PITA for you. You're either going to have to find a "friendly" SMTP server, ask the user to input their SMTP server's address, or find some way to automagically figure out an SMTP server to use.
You should definitely use the code from TimCotee's link. Using MAPI or CDO is fine, provided the user has it installed on their machine, AND has it configured correctly. If you use the code he links to, all they need is a TCP/IP stack, which AFAIK is pretty standard (grin.)
You can still run into logistical problems with this code, namely deciding what mail sever to connect to. If this app is for use within one specific company, you can just use the company's internal e-mail server. If this app is going to be used by people from multiple domains (DNS, not NT), you may run into problems with people from ABC corp not being able to send e-mail through XYZ corp's SMTP server. This is relatively nice to try to keep spam down, but a PITA for you. You're either going to have to find a "friendly" SMTP server, ask the user to input their SMTP server's address, or find some way to automagically figure out an SMTP server to use.
You can still run into logistical problems with this code, namely deciding what mail sever to connect to. If this app is for use within one specific company, you can just use the company's internal e-mail server. If this app is going to be used by people from multiple domains (DNS, not NT), you may run into problems with people from ABC corp not being able to send e-mail through XYZ corp's SMTP server. This is relatively nice to try to keep spam down, but a PITA for you. You're either going to have to find a "friendly" SMTP server, ask the user to input their SMTP server's address, or find some way to automagically figure out an SMTP server to use.
ASKER
Thank you so much guys, I liked and appreciate all your help.
Shows how to create a sendmail application from VB.