seanlhall
asked on
How can I send email using VBA when MS Outlook is not installed?
I have a MS Access run time application. Email is sent via the application uses MS Outlook as I have referenced MS Outlook 12. Some customers don't have Outlook. This did not use to be a problem, they could use Outlook Express or Windows Mail. Windows 7 does not have either. Window Live Mail is the replacement but installing it does not fix the reference problem. Any ideas?
Did you check whether Windows Live mail is your default mail application?
How is the email being sent? Can you post the code?
use CDO as the base object library.
e.g.
Dim CDO_Mail_Object As Object
Dim CDO_Config As Object
Dim SMTP_Config As Variant
Dim Email_Send_From As String
Dim eStep As Long
Email_Send_From = "whoever@whatever.com" ' sender email address
eStep = 1
Set CDO_Mail_Object = CreateObject("CDO.Message" )
Set CDO_Config = CreateObject("CDO.Configur ation")
eStep = 11
CDO_Config.Load -1
Set SMTP_Config = CDO_Config.Fields
With SMTP_Config
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = tServer 'valid server
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
'MsgBox "set smptp server name"
eStep = 2
With CDO_Mail_Object
Set .Configuration = CDO_Config
End With
CDO_Mail_Object.Subject = tSubject
CDO_Mail_Object.From = Email_Send_From
CDO_Mail_Object.To = tRecipients
CDO_Mail_Object.TextBody = tBody
'CDO_Mail_Object.cc = Email_Cc 'Use if needed
'CDO_Mail_Object.BCC = Email_Bcc 'Use if needed
eStep = 3
CDO_Mail_Object.AddAttachm ent tAttachment 'Use if needed
eStep = 4
CDO_Mail_Object.send
Dim CDO_Mail_Object As Object
Dim CDO_Config As Object
Dim SMTP_Config As Variant
Dim Email_Send_From As String
Dim eStep As Long
Email_Send_From = "whoever@whatever.com" ' sender email address
eStep = 1
Set CDO_Mail_Object = CreateObject("CDO.Message"
Set CDO_Config = CreateObject("CDO.Configur
eStep = 11
CDO_Config.Load -1
Set SMTP_Config = CDO_Config.Fields
With SMTP_Config
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = tServer 'valid server
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
'MsgBox "set smptp server name"
eStep = 2
With CDO_Mail_Object
Set .Configuration = CDO_Config
End With
CDO_Mail_Object.Subject = tSubject
CDO_Mail_Object.From = Email_Send_From
CDO_Mail_Object.To = tRecipients
CDO_Mail_Object.TextBody = tBody
'CDO_Mail_Object.cc = Email_Cc 'Use if needed
'CDO_Mail_Object.BCC = Email_Bcc 'Use if needed
eStep = 3
CDO_Mail_Object.AddAttachm
eStep = 4
CDO_Mail_Object.send
Besides CDO, you can also talk directly to an SMTP server (relies on no e-mail client being installed) either with this:
http://www.freevbcode.com/ShowCode.Asp?ID=109
or BLAT:
http://www.blat.net/
BLAT comes as a command line EXE (which you can shell to) or a DLL, which can be access through VBA.
JimD.
If you are using Code similar to this:
http://support.microsoft.com/kb/161088
(Just learned)
You can add this line in:
Set objOutlook = CreateObject("Outlook.Appl ication")
objOutlook.session.Logon '<---Add this line
...This will log you in and you can "Create/view" your email.
(I'm not sure if the message will sit in the outbox until Outlook is started up normally though)
Then obviously you will have to add:
objOutlook.session.Logoff
...to the end of the code
JeffCoachman
http://support.microsoft.com/kb/161088
(Just learned)
You can add this line in:
Set objOutlook = CreateObject("Outlook.Appl
objOutlook.session.Logon '<---Add this line
...This will log you in and you can "Create/view" your email.
(I'm not sure if the message will sit in the outbox until Outlook is started up normally though)
Then obviously you will have to add:
objOutlook.session.Logoff
...to the end of the code
JeffCoachman
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ok
I use Codestone's Internet Mail Library:
www.codestone.co.uk
It's easy to install and requires no real setup. You do need to have a valid URL to an smtp server, but you'll need that regardless of what you use.
www.codestone.co.uk
It's easy to install and requires no real setup. You do need to have a valid URL to an smtp server, but you'll need that regardless of what you use.
ASKER
Sorry for the delyed response. Thank you for the solution.