sammers101
Registered User.
- Local time
- Today, 09:20
- Joined
- May 11, 2012
- Messages
- 89
Is it possible with CBO to reference a report or a form with something like the following?
Currently I am attaching my report as an attachment but I would prefer to have it in the actual email instead. I'm using runtime access. I was also having problems adding a loop to DoCmd.GoToRecord , , acNext
My current code:
Code:
.TextBody = "customerComics"
My current code:
Code:
DoCmd.OutputTo acOutputReport, "customerComics", acFormatPDF, "C:\delete\pulls.pdf"
On Error GoTo errHandler
Dim cdoConfig As Object
Dim cdoMessage As Object
'create email object
Set cdoConfig = CreateObject("CDO.Configuration")
Set cdoMessage = CreateObject("CDO.Message")
'setup server configuration
With cdoConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = "465"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = "2"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = "-1"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = "60"
'following settings are optional
'.Item("http://schemas.microsoft.com/cdo/configuration/smtpaccountname") = "The DB Guy"
'.Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "thedbguy@gmail.com"
'.Item("http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress") = "thedbguy@gmail.com"
'warning: it's a security risk to hard-code your username and password
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.Update
End With
'build and send email message
With cdoMessage
Set .Configuration = cdoConfig
.From = "username@gmail.com"
.to = Me.fldEmail
'.Cc = "copy@email.address"
'.Bcc = "blind.copy@email.address"
.Subject = "Sub"
.TextBody = ""
'.HTMLBody = "<h2>Use this to send email as HTML.</h2>"
.AddAttachment "C:\delete\pulls.pdf"
.Send
End With
DoCmd.GoToRecord , , acNext
errExit:
Set cdoConfig = Nothing
Set cdoMessage = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
Resume errExit