Prev: Icons in tab pages
Next: Save Button
From: David W. Fenton on 2 May 2010 16:55 "Douglas J. Steele" <NOSPAM_djsteele(a)NOSPAM_gmail.com> wrote in news:uvC67me6KHA.5848(a)TK2MSFTNGP06.phx.gbl: > I believe you need > > Set myout = CreateObject("Outlook.Application", "localhost") > > although the following may suffice: > > Set myout = CreateObject("Outlook.Application") The first makes explicit what is already the default (and optional) parameter for CreateObject. I have discovered that leaving it out can cause automation to be blocked by certain security software, while supplying it explicitly results in it working. Why this is so, I can't imagine, since I'd assume code running with a default parameter defined and with the default parameter undefined would be exactly the same when it passes by the security software, but apparently not! -- David W. Fenton http://www.dfenton.com/ usenet at dfenton dot com http://www.dfenton.com/DFA/
From: Douglas J. Steele on 2 May 2010 17:56 Note that he's missing the quotes around "Outlook.Application" -- Doug Steele, Microsoft Access MVP http://www.AccessMVP.com/djsteele (no e-mails, please!) "David W. Fenton" <XXXusenet(a)dfenton.com.invalid> wrote in message news:Xns9D6CABF724C46f99a49ed1d0c49c5bbb2(a)74.209.136.93... > "Bob Vance" <rjvance(a)ihug.co.nz> wrote in > news:egmngtZ6KHA.3184(a)TK2MSFTNGP05.phx.gbl: > >> The Highlighted row was: >> Set myout = CreateObject(Outlook.Application, "localhost") > > As you reported earlier, the error was: > >>> Error Number 463 >>> Description: Class not registered on local machine > > Doug suggested you try removing the "localhost" (it shouldn't make a > difference, as that's the default, but if you leave it out, it can > be blocked by some security software). > > The message is not believable, given that you had previously used > early binding, with a reference to Outlook, right? > > Try repairing your Office installation and trying again. > > Also, did you fix the olMailItem problem? The line of code > immediately after the offending line in the code you posted has a > reference to that constant, which will be undefined without the > reference (unless you redefined it yourself). I know it's not the > highlighted line, but it's worth a try. Of course, it should give > you a compile error instead of a runtime error. You *do* compile > your code, right? > > -- > David W. Fenton http://www.dfenton.com/ > usenet at dfenton dot com http://www.dfenton.com/DFA/
From: Bob Vance on 2 May 2010 20:04 "David W. Fenton" <XXXusenet(a)dfenton.com.invalid> wrote in message news:Xns9D6CABF724C46f99a49ed1d0c49c5bbb2(a)74.209.136.93... > "Bob Vance" <rjvance(a)ihug.co.nz> wrote in > news:egmngtZ6KHA.3184(a)TK2MSFTNGP05.phx.gbl: > >> The Highlighted row was: >> Set myout = CreateObject(Outlook.Application, "localhost") > > As you reported earlier, the error was: > >>> Error Number 463 >>> Description: Class not registered on local machine > > Doug suggested you try removing the "localhost" (it shouldn't make a > difference, as that's the default, but if you leave it out, it can > be blocked by some security software). > > The message is not believable, given that you had previously used > early binding, with a reference to Outlook, right? > > Try repairing your Office installation and trying again. > > Also, did you fix the olMailItem problem? The line of code > immediately after the offending line in the code you posted has a > reference to that constant, which will be undefined without the > reference (unless you redefined it yourself). I know it's not the > highlighted line, but it's worth a try. Of course, it should give > you a compile error instead of a runtime error. You *do* compile > your code, right? > > -- > David W. Fenton http://www.dfenton.com/ > usenet at dfenton dot com http://www.dfenton.com/DFA/ Thanks David, I am not getting any error messages and my 2 reports are going to my Local Directory but not going to Outlook! 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 Object Dim myout As Object 'Set myout = CreateObject("Outlook.Application", "localhost") Set myout = CreateObject("Outlook.Application") 'Set myitem = myout.CreateItem(olMailItem) Set myitem = myout.CreateItem(0) 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 3 May 2010 15:42 "Douglas J. Steele" <NOSPAM_djsteele(a)NOSPAM_gmail.com> wrote in news:O3DQfJk6KHA.1888(a)TK2MSFTNGP05.phx.gbl: > Note that he's missing the quotes around "Outlook.Application" Hmm. I'd think that wouldn't compile unless you still had the reference. Of course, if the reference is still there, that would explain why olMailItem doesn't throw a compile error. -- David W. Fenton http://www.dfenton.com/ usenet at dfenton dot com http://www.dfenton.com/DFA/
From: David W. Fenton on 3 May 2010 15:43
"Bob Vance" <rjvance(a)ihug.co.nz> wrote in news:uyK1eQl6KHA.1424(a)TK2MSFTNGP04.phx.gbl: > I am not getting any error messages and my 2 reports are going > to my Local Directory but not going to Outlook! I recall having significant problems with attachments. I think you have to save the message for it to take, but I could be misremembering that. -- David W. Fenton http://www.dfenton.com/ usenet at dfenton dot com http://www.dfenton.com/DFA/ |