From: Bob Vance on

>> Microsoft DAO 3.6 Object Library
>>
>> For these:
>>
>> Visual Basic For Application
>> Microsoft Access 12.0 Object Library
>> OLE Automation
>> Microsoft ActiveX Data Objects 2.1 Library
>> Microsoft Visual Basic for Application Extensilbilty 5.3
>
> Why do you think you need this one?
>
>> Microsoft Outlook 12 Object Library
>
> Use late binding with Outlook to avoid needing a reference. If you
> do that, all your non-Outlook code will run on machines without
> Outlook installed.
>
>> Microsoft Office 12.0 Access database engine Object Library
>
> This last is just DAO for A2007.
>
> --
> David W. Fenton http://www.dfenton.com/
> usenet at dfenton dot com http://www.dfenton.com/DFA/

Thanks David , I removed "Microsoft Visual Basic for Application
Extensilbilty 5.3" and my email output worked fine!
My Output seems to be CreateItem, can I change this code for Late Binding
maybe CreateObject??
Regards Bob
--------------------------------------------------------
Private Sub SendMailButton_Click()

On Error GoTo ErrorHandler
If Me.Dirty = True Then
Me.Dirty = False
Dim myfile1 As String, myfile2 As String
End If
Dim mydir As String
mydir = Left(CurrentDb.Name, Len(CurrentDb.Name) -
Len(Dir(CurrentDb.Name)))
Dim lngID As Long, strMail As String, strBodyMsg As String, _
blEditMail As Boolean, sndReport As String, strCompany As String
Dim msgPmt As String, msgBtns As Integer, msgTitle As String, msgResp As
Integer, tbAmount As String
Dim strFormat As String
Dim mytot As Long
mytot = DCount("[InvoiceID]", "qrySelInvoices", "")

Select Case Me.tbEmailOption.value

Case "ADOBE"
strFormat = acFormatPDF
myfile1 = mydir & "Statement.pdf"
myfile2 = mydir & "Invoice.pdf"
Case "WORD"
strFormat = acFormatRTF
myfile1 = mydir & "Statement.rtf"
myfile2 = mydir & "Invoice.rtf"

Case "SNAPSHOT"
strFormat = acFormatSNP
myfile1 = mydir & "Statement.SNP"
myfile2 = mydir & "Invoice.SNP"

Case "TEXT"
strFormat = acFormatTXT
myfile1 = mydir & "Statement.txt"
myfile2 = mydir & "Invoice.txt"

Case "HTML"
strFormat = acFormatHTML
myfile1 = mydir & "Statement.htm"
myfile2 = mydir & "Invoice.htm"

Case Else ' catch all others
strFormat = acFormatHTML
myfile1 = mydir & "Statement.htm"
myfile2 = mydir & "Invoice.htm"

End Select

Select Case Me.OpenArgs

Case "OwnerStatement"

sndReport = "rptOwnerPaymentMethod"


lngID = Nz(Me.cbOwnerName.Column(0), 0)
strMail = OwnerEmailAddress(lngID)
tbAmount = Nz(Me.cbOwnerName.Column(5), 0)

strBodyMsg = "To: "
strBodyMsg = strBodyMsg & Nz(DLookup("[ClientTitle]",
"tblOwnerInfo", _
"[OwnerID]=" & lngID), " ") & " "
strBodyMsg = strBodyMsg & Nz(DLookup("[OwnerLastName]",
"tblOwnerInfo", _
"[OwnerID]=" & lngID), " Owner")
strBodyMsg = strBodyMsg & "," & Chr(10) & Chr(10) & Chr(13) _
& "Please find attached your Statement, Dated:" & " " &
Format(Date, "d-mmm-yyyy") & Chr(10) & "Your Statement Total: " &
Format(tbAmount, "$ #,##.00") & Chr(10) & Chr(10) &
Nz(DLookup("[EmailMessage]", "tblCompanyInfo"), "") & eMailSignature("Best
Regards", True) & Chr(10) & Chr(10) & DownloadMessage("PDF") _


DoCmd.OutputTo acOutputReport, sndReport, strFormat,
myfile1, False
If mytot > 0 Then
DoCmd.OutputTo acOutputReport, "rptInvoiceModify",
strFormat, myfile2, False
End If

CurrentDb.Execute "UPDATE tblOwnerInfo " & _
"SET EmailDateState = Now() " & _
"WHERE OwnerID = " & lngID, dbFailOnError
Dim myitem As Outlook.MailItem
Dim myout As Outlook.Application
Set myout = New Outlook.Application
Set myitem = myout.CreateItem(olMailItem)
With myitem
.To = strMail
.CC = Nz(DLookup("EmailCC", "tblOwnerInfo", "OwnerID = " & lngID), "")
.Bcc = Nz(DLookup("EmailBCC", "tblOwnerInfo", "OwnerID = " & lngID), "")
.Subject = "Your Statement" & " / " & Nz(DLookup("[CompanyName]",
"tblCompanyInfo"))
.Body = strBodyMsg 'EditMessage:=blEditMail
.Attachments.Add myfile1
If mytot > 0 Then
.Attachments.Add myfile2
End If
On Error Resume Next
.Send
On Error GoTo ErrorHandler
End With
Set myitem = Nothing
Set myout = Nothing
cbOwnerName.SetFocus

Case Else
Exit Sub

End Select
ExitProc:
Exit Sub
ErrorHandler:

msgTitle = "Untrapped Error"
msgBtns = vbExclamation

Select Case Err.Number
'User cancelled message (2293 & 2296 are raised
'by Outlook, not Outlook Express).
Case 2501, 2293, 2296
Case Else
MsgBox "Error Number: " & Err.Number & Chr(13) _
& "Description: " & Err.Description & Chr(13) & Chr(13) _
& "(frmBillStatement SendMailButton_Click)", msgBtns, msgTitle
End Select

Resume ExitProc

End Sub


From: David W. Fenton on
"Bob Vance" <rjvance(a)ihug.co.nz> wrote in
news:O$uof$15KHA.3804(a)TK2MSFTNGP05.phx.gbl:

> Dim myitem As Outlook.MailItem
> Dim myout As Outlook.Application
> Set myout = New Outlook.Application
> Set myitem = myout.CreateItem(olMailItem)

Change these to this:

Dim myitem As Object
Dim myout As Object
Set myout = CreateObject(Outlook.Application, "localhost")
Set myitem = myout.CreateItem(olMailItem)

....and hyou should be set.

The key is that you don't use any of the Outlook data types, and use
object variables instead.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
From: Douglas J. Steele on
"David W. Fenton" <XXXusenet(a)dfenton.com.invalid> wrote in message
news:Xns9D69C5E86A7A7f99a49ed1d0c49c5bbb2(a)74.209.136.82...
> "Bob Vance" <rjvance(a)ihug.co.nz> wrote in
> news:O$uof$15KHA.3804(a)TK2MSFTNGP05.phx.gbl:
>
>> Dim myitem As Outlook.MailItem
>> Dim myout As Outlook.Application
>> Set myout = New Outlook.Application
>> Set myitem = myout.CreateItem(olMailItem)
>
> Change these to this:
>
> Dim myitem As Object
> Dim myout As Object
> Set myout = CreateObject(Outlook.Application, "localhost")
> Set myitem = myout.CreateItem(olMailItem)
>
> ...and hyou should be set.
>
> The key is that you don't use any of the Outlook data types, and use
> object variables instead.

He'll also need to fix the line of code

Set myitem = myout.CreateItem(olMailItem)

Either change it to

Set myitem = myout.CreateItem(0)

or else add a declaration of the olMailItem constant

Const olMailItem As Long = 0

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)




From: Bob Vance on

"Douglas J. Steele" <NOSPAM_djsteele(a)NOSPAM_gmail.com> wrote in message
news:%23Gd4NdB6KHA.5440(a)TK2MSFTNGP06.phx.gbl...
> "David W. Fenton" <XXXusenet(a)dfenton.com.invalid> wrote in message
> news:Xns9D69C5E86A7A7f99a49ed1d0c49c5bbb2(a)74.209.136.82...
>> "Bob Vance" <rjvance(a)ihug.co.nz> wrote in
>> news:O$uof$15KHA.3804(a)TK2MSFTNGP05.phx.gbl:
>>
>>> Dim myitem As Outlook.MailItem
>>> Dim myout As Outlook.Application
>>> Set myout = New Outlook.Application
>>> Set myitem = myout.CreateItem(olMailItem)
>>
>> Change these to this:
>>
>> Dim myitem As Object
>> Dim myout As Object
>> Set myout = CreateObject(Outlook.Application, "localhost")
>> Set myitem = myout.CreateItem(olMailItem)
>>
>> ...and hyou should be set.
>>
>> The key is that you don't use any of the Outlook data types, and use
>> object variables instead.
>
> He'll also need to fix the line of code
>
> Set myitem = myout.CreateItem(olMailItem)
>
> Either change it to
>
> Set myitem = myout.CreateItem(0)
>
> or else add a declaration of the olMailItem constant
>
> Const olMailItem As Long = 0
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)

Thanks Guys, I did what you said and got this error
Error Number 463
Description: Class not registered on local machine
Regards Bob


From: David W. Fenton on
"Bob Vance" <rjvance(a)ihug.co.nz> wrote in
news:uXgR3qD6KHA.3656(a)TK2MSFTNGP06.phx.gbl:

> I did what you said and got this error
> Error Number 463
> Description: Class not registered on local machine
> Regards Bob

Which line of code as highlighted as producing that error?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9
Prev: Icons in tab pages
Next: Save Button