E-Mail Report Thru ISP Mail, without Outlook

quest4

Registered User.
Local time
Today, 06:28
Joined
Oct 12, 2004
Messages
246
Good afternoon, I have a report that I am trying to e-mail with roadrunner web mail and Outlook is not on the computer. I ahve thought about just sending it to a file, but snapshot and html and RT would not open or would ask what program to open them with, when I double-clicked on them. SendObject worked fairly well when using Outlook and a network mail server, but this will be in a private home with neither available, only RR Web Mail. Any ideas on any procedure or known methods of doing this will be greatly appreciated. Thank you in advance for any assistance rendered.:eek::confused:
 
Thanks again for the help, but I have a couple of unsolved questions. In references I added CDO for Windows and I am running on XP Pro, so do I have the correct Reference? I did put this in a module, but I can not get it to work in a macro using RunCode, so how do I get it to work? Last question that I can think of, do I need IE open when i run the report? Thanks again for the help.
 
Q:
It might be more reliable if you late bind rather than set that CDO reference.
Code:
[COLOR="green"]'Change this...[/COLOR]
Dim iMsg As New CDO.Message
Dim iConf As New CDO.Configuration
[COLOR="Green"]'...to this...[/COLOR]
Dim iMsg as object
Dim iConf as object
set iMsg = createobject("CDO.Message")
set iConf = createobject("CDO.Configuration")

I've never used macros so I can't help you there. I keep this code in a standard module called Mail in a referenced library database called Lib, so I call this routine like this...
Code:
private sub cmdSendMail_click()
  Lib.Mail.Send me.recipients, me.sender, me.subject, me.mailserver
end sub
...which assumes the current object contains said members. And no, this has nothing to do with IE or with any report.
Hope this helps.
 
Thank you very much for the response lagbolt. Like I have said, it has been a minute or two sense I last did this and I am a bit rusty and I followed everything except the reference library database. Is the a separate dabe with modMail as the onlt Item or what? I have not used that method even when I did build dbases. One last dumb question, in the private statement, would I put that in the report's On Click or where? Thank you again for all of your help, I deeply appreciate it.
 
Thank you very much for your response lagbolt. It has been a couple of years sense I last built databases and I am a bit rusty at it right now. I did understand what you said till you said put modMail in a reference library database. Do you mean put it in a separate database as a module or what? Even when i was making Databases, I did not hear about that one. One last dumb questionwith the private procedure, do I put that in the reports OnClick event or cmdButton or what? Thanks you again for all of the help, it is deeply appreciated.
 
Dont worry about the library stuff. Just put it in a standard module and run it as you would any other subroutine.
Also, the constants in that code, if you late bind, should be...
Code:
cdoSendUsingPort = 2
cdoAnonymous = 0
The private procedure is the event handler for a command button click event.
 
Thanks alot for the response lagbolt. I have changed the code to a late bind as above and I put them in a standard module called modMail. Now I have a standard switchboard with a cmdButton on it and that is how I run a simple macro which just prints the report and at that point I was trying to use RunCode to e-mail that report. It sounds like I should be putting the private sub on the OnClick of the switchboard cmdButton, is that correct? Now please tell me were the last 2 lines of code go? Thanks again for the help.
 
Yes, if you have a button that generates a report you want to send that is a good place to run this code. But the last two lines of code? You mean those constant?
Code:
[SIZE="1"].item("http://schemas.microsoft.com/cdo/configuration/sendusing") = [COLOR="DarkRed"]2[/COLOR]   [COLOR="Green"]'cdoSendUsingPort[/COLOR]
.item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
.item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = [COLOR="darkred"]0[/COLOR]  [COLOR="green"]'cdoAnonymous[/COLOR][/SIZE]
If you late bind, and the CDO object model is no longer referenced by your code, then those constants will not be available. You must then replace them with numbers.
Cheers
 
Thanks again for the response. I modified the module like you said and it now looks like this:
Public Sub Send(recipients As String, from As String, subject As String, smtpServer As String, Optional msg As String, Optional attachPath As String)
On Error GoTo handler
Dim iMsg As Object
Dim iConf As Object
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
'set up configuration
With iConf
With .Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp-server.neo.rr.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0 'cdoAnonymous
.Update
End With
End With
'configure message
With iMsg
Set .Configuration = iConf
.To = "sendto address"
.from = "sentfrom address"
.subject = "Daily Transcription Report"
If msg <> "" Then .TextBody = msg
If attachPath <> "" Then .AddAttachment attachPath
.Send
End With
'tidy up
Set iMsg = Nothing
Set iConf = Nothing
Exit Sub
handler:
Err.Raise Err, Err.Source & " - Lib.Mail.Send()"
End Sub
I hope that I got it right, but then I went into the switchboard to add the private su to the OnClick of the cmdBotton, it would only allow no to use the expression builder and would not let me even get to the code to add anything. Does this mean that I should probably make my own switchboard from a form, so I can add that code? Thanks again for all of the help.
 
Last edited:
I tried this after putting in the subroutine in the reports OnClick and it errors out tell me it can not find things like Me.recipients and so on. Here is the OnClick code:
Private Sub PrintqselReportData_Daily_Click()
On Error GoTo Err_PrintqselReportData_Daily_Click
Dim stDocName As String
stDocName = "rptqselReportData-Daily"
DoCmd.OpenReport stDocName, acNormal
Lib.Mail.Send Me.recipients, Me.Sender, Me.subject, Me.mailserver
Exit_PrintqselReportData_Daily_Click:
Exit Sub
Err_PrintqselReportData_Daily_Click:
MsgBox Err.Description
Resume Exit_PrintqselReportData_Daily_Click
End Sub
Could someone please tell me what I am doing wrong? I have tried commenting out most of the lines and still nothing. The module is rihgt above this post. Thank you to anyone helping out with this problem.
 
- Recipients is a parameter. You need to pass in a string that contains something like "Bob <bob@comcast.net>". You need to do this for each parameter.
- Me is an object reference to the object in which code is currently running. For that code to work you need a property or textbox or something in the current block of code that exposes something called Recipients that contains a string.
- You don't need Lib.Mail in front of the function call unless your routine is contained by an object called Mail which is in turn contained by an object called Lib.
- I think you need to learn some basics about how to call a subroutine in VBA. Search Access VBA help for 'Calling Sub and Function Procedures'. To search VBA help, open a code window, and use the Help option from the menu of the code window.
- Way to keep at it.
 
Thanks for the response, I will give it a try. Oh, a few years ago when i used to work on and design this beasts, I used to know this stuff pretty well, but you know the old saying, if you don't use it you lose it. And that is what happened.
 

Users who are viewing this thread

Back
Top Bottom