Emailing from Access

  • Thread starter Thread starter APH
  • Start date Start date
A

APH

Hi

1. I have some code that uses Outlook to email directly from Access.
However when sending the emails, each email activates a message from Outlook
saying that a program is trying to automatically send a message - do I want
to allow it. Is there anyway to switch this off

2. Is there anyway in the code to specify which email account is to be
used - at present it uses the defaculy email account on the machine running
the code. We need to specify who the email is from and the reply address

3. I assume that using Outlook is the best way to send these emails - wasn't
sue if perhaps I should be suing somethign like CDONTS

Thanks

Alex
 
APH,

I think what you are referring to is a security feature of Outlook. As
far as I know, this can not be disabled, although a post to an Outlook
newsgroup may get you a more authoritative opinion on this. I know that
some people have had success with overcoming this problem using a free
utility called ClickYes. See
http://www.express-soft.com/mailmate/clickyes.html

You don't mention which code you are using to send the emails, so a
specific response to your other questions is difficult. For some good
information relating to emailing from within Access, see
http://www.granite.ab.ca/access/email.htm and also check out the Total
Access Emailer at http://www.fmsinc.com/products/Emailer/index.asp
 
Steve thanks for your response - will look at those I like the idea behind
fmsinc, but not the price !!

My current code is:
Public Sub Email()

Dim rsEmailrecs As ADODB.Recordset
Dim objOutlook As New Outlook.Application
Dim objMessage As MailItem
Dim strMessage As String


Set rsEmailrecs = New ADODB.Recordset

rsEmailrecs.Open "QryFollowUp", CurrentProject.Connection

With rsEmailrecs
While Not rsEmailrecs.EOF
strMessage = "Dear " & rsEmailrecs("Title") & " " &
rsEmailrecs("Surname") & _
vbCrLf & vbCrFl & _
"text of email goes here suitable formatted"
If Not IsNull(rsEmailrecs("tblContacts.email")) Then
Set objMessage = objOutlook.CreateItem(MailItem)
With objMessage
.To = "(e-mail address removed)
.Subject = "Subject text goes here.
.body = strMessage
.send
End With
End If

This of course is using Outlook which i am now shying away from on this
occasion.

Could I use CDONTS?

Alex
 
Alex,

I am sorry, I am not able to answer your question. I am not familiar
with CDONTS. I have clients whose default email programme is Outlook
Express, and they do not experience this problem. I use the FMS product
I mentioned before.
 
Thanks anyway Steve. I might use the FMS product - looks good if a little
expensive. will download the trial and try it.

Alex
 
Alex

I don't think you want to use CDONTS as Msoft is depreciating that code in
favor of CDO. If all of your clients are win 2K or better you should be
able to use CDO. Below is a test Sub that you can try:

Public Sub testCDO()
' Purpose Send an Email with or without an attachment without using
Outlook or other MAPI client
' Uses Late Binding - Does not need a reference to the Microsoft
CDO For Windows library

Const cdoSendUsingPort = 2
' Const cdoBasic = 1
Dim cdoConfig As Object, cdoMessage As Object
Dim sch As String

sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = cdoSendUsingPort
.Item(sch & "smtpserver") = "SomeSMTPServer.COM"
'Only used if SMTP server requires Authentication
'.Item(sch & "SMTPAuthenticate") = cdoBasic
'.Item(sch & "SendUserName") = "Username"
'.Item(sch & "SendPassword") = "Password"
.Update
End With

Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "(e-mail address removed)"
.To = "(e-mail address removed)"
.Subject = "Sample CDO Message"
' Can send plain text
'.TextBody = "This is a test for a text CDO message"
' Or can send HTML formatted text
.HTMLBody = "This is not Bold But <B>This is!</B>"
' Attachments are easy
.AddAttachment "c:\SomeDir\SomeFile.txt"
.AddAttachment "c:\AnotherDir\AnotherFile.txt"
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing

End Sub

Obviously this code will fail if CDOSYS.DLL is not registered in the users
machine. This code will cause an Email to be sent WITHOUT the user getting
any prompt whatsoever.

Ron W
 
Ron

Thank you VERY much indeed. Will try that later today - seems that will do
what I want

Cheers

Alex
 
Back
Top