Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Invoices by Email without going through MS Outlook 4

Status
Not open for further replies.

PercyN

Programmer
May 16, 2007
86
Guys,
I have a small program that sends invoices by email. Currently I do it through MS Outlook but I know there is a way to send the mail directly from access. I have seen it done in a few programs and I have tried to get help on it but all the help in MSDN seem to be more about using MS Outlook. Any ideas?

Thanks
Percy
 
Have a look at the DoCmd.SendObject method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV.
I have checked it out, I think I tried using it some time back but I think it will still require an email program like MS outlook to work. The one I saw in the program I mentioned earlier required the user to specify an SMTP, POP3 and stuff like that. This way it creates and sends the mail directly without using or passing through another mail software.
 
Do a search for CDO

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I have tried doing a search with CDO but trust me there is a lot of irrelevant stuff. If anyone has an idea how the code will look like (methods to use etc) I'm sure I will be able to figure out the rest.

Thanks
Percy
 
A starting point:
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "your subject here"
objMessage.Sender = "sendername@somedomain.com"
objMessage.To = "somename@domain.com"
objMessage.TextBody = "your body text here"
With objMessage.Configuration.Fields
.Item(" = 2
.Item(" = "smtp.someserver.com"
.Item(" = 25
.Update
End With
objMessage.Send

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Great! I'll try it and get back

Thanks
Percy
 
I've been using a free command line executable from It allows me to programmatically send attachments with emails without the computer having to have Outlook. All it needs is to have SMTP available on the computer.
 
I believe that I found an answer to the same question on the forum last year, sorry, don't remember who submitted it, but it works:

Sub SendCDO()
Dim dbs As DATABASE
Set dbs = CurrentDb
Dim nbUser As Long
nbUser = Forms!frmCalender!cboUser
Dim rstS As Recordset
Set rstS = dbs.OpenRecordset("SELECT tblUser.UserID, tblUser.UserEmail, tblUser.ReportTo, tblUser.ReportToEmail " _
& "FROM tblUser WHERE (((tblUser.UserID) = " & nbUser & "));")

Dim email As New CDO.message

With email
.AddAttachment "C:\VacRequest.txt"
.HTMLBody = "<H4>Please review attached file.</H4>"
.From = rstS!UserEmail
.To = rstS!ReportToEmail
.Subject = "Time-Off Request"

.Configuration.Fields.Item _
(" = 2

'Name or IP of Remote SMTP Server
.Configuration.Fields.Item _
(" = "smtp.wellpoint.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
.Configuration.Fields.Item _
(" = cdoBasic

'Your UserID on the SMTP server
.Configuration.Fields.Item _
(" = "xxxxxxxxx"

'Your password on the SMTP server
.Configuration.Fields.Item _
(" = "xxxxxxxxx"

'Server port (typically 25)
.Configuration.Fields.Item _
(" = 25

'Use SSL for the connection (False or True)
.Configuration.Fields.Item _
(" = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
.Configuration.Fields.Item _
(" = 60

.Configuration.Fields.Update
'==End remote SMTP server configuration section==

.Send
End With
End Sub
 
How would you add an attachment using the objmessage

ck1999
 
on Paul Sadowski's site that I mentioned earlier...

objmessage.AddAttachment "C:\YourFolder\YourFile.ext"


May be repeated to include multiple attachments.


~Melagan
______
"It's never too late to become what you might have been.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top