Sending E-mail

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I have this code that works very well, except I want to send the contents of
a small report in the body of an E-Mail. Right now I'm transferring the
report to a txt file, works fine. How can I get that to the body of the E-
Mail?

Const cdoSendUsingPort = 2
Const cdoBasic = 1
Dim objCDOConfig As Object, objCDOMessage As Object
Dim strSch As String

strSch = "http://schemas.microsoft.com/cdo/configuration/"
Set objCDOConfig = CreateObject("CDO.Configuration")
With objCDOConfig.Fields
.Item(strSch & "sendusing") = cdoSendUsingPort
.Item(strSch & "smtpserver") = "mail.optonline.net"
.Item(strSch & "smtpauthenticate") = cdoBasic
.Item(strSch & "sendusername") = "Big Corp"
.Item(strSch & "sendpassword") = "99"
.Update
End With

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig
.FROM = "Big Corp"
.sender = "(e-mail address removed)"
.TO = "(e-mail address removed)"
.subject = "SALES UPDATE"
.TextBody = "This should be the contents of the text file that is
from the report "
.SEND
End With
Set objCDOMessage = Nothing
Set objCDOConfig = Nothing

Thanks
DS
 
DS said:
I have this code that works very well, except I want to send the contents of
a small report in the body of an E-Mail. Right now I'm transferring the
report to a txt file, works fine. How can I get that to the body of the E-
Mail?

You'll need to get the contents of that report into a string variable.
Of course you can't do that. So the method is read the same data
that's on the report into a string variable. At least one recordset
read and maybe multiple looping through records.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
DS said:
I have this code that works very well, except I want to send the contents
of
a small report in the body of an E-Mail. Right now I'm transferring the
report to a txt file, works fine. How can I get that to the body of the
E-
Mail?

Const cdoSendUsingPort = 2
Const cdoBasic = 1
Dim objCDOConfig As Object, objCDOMessage As Object
Dim strSch As String

strSch = "http://schemas.microsoft.com/cdo/configuration/"
Set objCDOConfig = CreateObject("CDO.Configuration")
With objCDOConfig.Fields
.Item(strSch & "sendusing") = cdoSendUsingPort
.Item(strSch & "smtpserver") = "mail.optonline.net"
.Item(strSch & "smtpauthenticate") = cdoBasic
.Item(strSch & "sendusername") = "Big Corp"
.Item(strSch & "sendpassword") = "99"
.Update
End With

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig
.FROM = "Big Corp"
.sender = "(e-mail address removed)"
.TO = "(e-mail address removed)"
.subject = "SALES UPDATE"
.TextBody = "This should be the contents of the text file that is
from the report "
.SEND
End With
Set objCDOMessage = Nothing
Set objCDOConfig = Nothing

Thanks
DS

Read the file into a string variable, like this:

Dim f As Integer, b As String

Open "MyFilePath.txt" For Binary Access Read as f
b = Space$(LOF(f))
Get #f, , b
Close f

Then assign it:

..TextBody = b
 
DS said:
I have this code that works very well, except I want to send the contents
of
a small report in the body of an E-Mail. Right now I'm transferring the
report to a txt file, works fine. How can I get that to the body of the
E-
Mail?

Const cdoSendUsingPort = 2
Const cdoBasic = 1
Dim objCDOConfig As Object, objCDOMessage As Object
Dim strSch As String

strSch = "http://schemas.microsoft.com/cdo/configuration/"
Set objCDOConfig = CreateObject("CDO.Configuration")
With objCDOConfig.Fields
.Item(strSch & "sendusing") = cdoSendUsingPort
.Item(strSch & "smtpserver") = "mail.optonline.net"
.Item(strSch & "smtpauthenticate") = cdoBasic
.Item(strSch & "sendusername") = "Big Corp"
.Item(strSch & "sendpassword") = "99"
.Update
End With

Set objCDOMessage = CreateObject("CDO.Message")
With objCDOMessage
Set .Configuration = objCDOConfig
.FROM = "Big Corp"
.sender = "(e-mail address removed)"
.TO = "(e-mail address removed)"
.subject = "SALES UPDATE"
.TextBody = "This should be the contents of the text file that is
from the report "
.SEND
End With
Set objCDOMessage = Nothing
Set objCDOConfig = Nothing

Thanks
DS

Read the file into a string variable, like this:

Dim f As Integer, b As String

Open "MyFilePath.txt" For Binary Access Read as f
b = Space$(LOF(f))
Get #f, , b
Close f

Then assign it:

..TextBody = b
 
Back
Top