Unable to generate emails now.

T

TaylorGaffney

I have upgraded my laptop from XP SP2 to Vista SP1.

Since I have upgraded, I am unable to send these simple reports in an
access program I have created. I was able to do this for well over a
year before upgrading to Vista.

If you need more info, or questions please ask. I need to resolve
this quickly.

CODE:

Public Function PTOeMail(sTo As String, sSubject As String, sMsg As
String, Optional sCC As String, Optional sAttachment As String)

Dim olApp As Object
Dim myItem

On Error GoTo Email_GooFed

Set olApp = CreateObject("outlook.application")
Set myItem = olApp.Application.CreateItem(0)

myItem.To = sTo
myItem.Subject = sSubject
myItem.Body = sMsg
myItem.CC = sCC
myItem.Attachments.Add sAttachment
myItem.Send
EMail_ExIT:
Exit Function

Email_GooFed:
MsgBox "Your system was unable to generate the email message. " _
& "You will have to notify them differently if necessary.",
vbInformation
Resume EMail_ExIT

End Function

I get this message on every attempt.
<b>"Your system was unable to generate the email message. " _
& "You will have to notify them differently if necessary."</b>
 
T

TaylorGaffney

I actually run this CODE first before the first post.

Dim db As Database
Dim rs As Recordset, rs2 As Recordset, strClause As String, rptName As
String, i As Integer
Dim Email As String, fn As String, rtn
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl CSRs")
Set rs2 = db.OpenRecordset("qsl ComlogSelected")
Do Until rs.EOF
strClause = "CSR = " & "'" & rs![CSRCode] & "'"
rs2.FindFirst strClause
If Not rs2.NoMatch Then
rptName = "comlog" & rs![CSRCode]
DoCmd.OpenReport "rpt Comlog", acViewDesign
Reports![rpt Comlog].Caption = rptName
DoCmd.Close acReport, "rpt Comlog", acSaveYes
DoCmd.OpenReport "rpt Comlog", acViewNormal, , strClause
For i = 1 To 5000
DoEvents
Next i
fn = "c:\access02\" & rptName & ".pdf"
Email = rs![EmailAddress]
rtn = SendEmail(Email, fn)
End If
rs.MoveNext
Loop
rs.Close
rs2.Close
End Function

Thanks.
 
C

Clifford Bass

Hi Taylor,

What is the error number and description? Add this line to your
Email_GooFed part:

MsgBox Err.Number & ": " & Err.Description

Clifford Bass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top