I’m on Windows 2000 and Outlook 2000 and I only get
Microsoft CDO for NTS 1.2 Library and
Microsoft CDO for Windows 2000 Library
in my Tools -> Refrences list.
Both result in:
Run-time error ‘429’
ActiveX componnent cannot create object.
When I run the following code (from the top of all the email from BCA samples):
Private Sub Document_AfterRefresh()
Dim objSession As Object
Set objSession = CreateObject(“mapi.session”)
End Sub
So I cheated and copied CDO.DLL from my neighbors XP computer that his Tools->Refrences show’s is C:\Program Files\Common Files\System\mapi\1033\CDO.DLL. I put it in a new folder on my PC, called CDO1.DLL and it listed as Microsoft CDO 1.21 Library in my Tools->References after I browsed to it. Yahoooooooooooo…except it still fails with the ActiveX error. One example is a July 2000 BO version 5.0 doc called Send Microsoft Outlook e-mails with BCA, so I doubt it’s an XP thing.
Help. You know I need somebody. Not just anybody. - Beatles
Mahalo,
Zing
I have Outlook 2000 and Windows 2000 on my PC. My webI server has Outlook 5.0 and 2000 Adv Server. I’m switching from Outlook Objects to CDO because - the following code works on both machines when run from BO by clicking Refresh, but when run by BCA it fails due to the Outlook Objects not being compatable to run as an NT service:
Private Sub Document_AfterRefresh()
'This procedure emails a link to the PDF file to a long list
Set OlkApp = CreateObject(“Outlook.Application”)
Set NewMail = OlkApp.CreateItem(olMailItem)
Set attachments = NewMail.attachments
’ attachments.Add (“C:\Zingware\PDF\BusObj Status Report.pdf”)
With NewMail
.Importance = 2 'olImportanceHigh is not understood by SBL.
.To = “mike.sainz@cingular.com”
’ or you can put .To = “jdoe@industry.com”
’ or .CC = “Mary Smith”
.Subject = “Compass SDLC Status Report has been updated”
.Body = "Please click on the following link to retreive the Acrobat document into your web browser - " & String(1, 13) & String(1, 13)
.Body = .Body & "http://boreporting.sbms.sbc.com/BusObj%20Status%20Report.pdf. " & String(1, 13) & String(1, 13)
.Body = .Body & "If you are not able to retreive the document please reply to this email, "
.Body = .Body & "with a description of the problem and click send to send it to the "
.Body = .Body & “Business Objects Compass oncall mailbox.” & String(1, 13) & String(1, 13)
.Body = .Body & “Have a nice day!”
.Send
End With
End Sub
It adds attachments sends links and all kinds of grovy stuff but I’d have to manually refresh the report every day after opening it in BO.
I’m stuck in that I really need to get Microsoft CDO 1.2.1 Library working because all of the examples and sample code use it. I have a whole BO document here that shows the same solution for this exact problem and uses Microsoft CDO 1.21 Library (CDO.dll).
How do I register it? Is that the right thing to do on my PC and servers? Thanks for any help.
I tried my co-workers PC that has XP and Office 2000 and I finished the macro in 15 minutes.
I tried the macro using BCA on our WebI server and I got -2147221231 [Collaboration Data Objects - [MAPI_E_LOGON_FAILED(80040111)]] for the VBA Err.Number and Err.Description.
The user that BCA was installed with on that server is supposedly configured to use MSExchange with “MS Exchanges Settings” as the profile name. When I manually run the same code (below) using BO on that server it works for my account whis uses that profile name but not automatically from BCA.
Thanks for any help and here is a sample that works otherwise:
Private Sub Document_AfterRefresh()
On Error GoTo write_error
Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object
Set objSession = CreateObject("mapi.session")
objSession.Logon profileName:="MS Exchange Settings"
Set objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = "Test"
objMessage.Text = "Test"
Set objRecipient = objMessage.Recipients.Add
objRecipient.Name = "mike.sainz@cingular.com"
objRecipient.Type = mapiTo
objRecipient.Resolve
Set objRecipient = objMessage.Recipients.Add
objRecipient.Name = "BUSINESS.OBJECTS.COMPASS@cingular.com"
objRecipient.Type = mapiTo
objRecipient.Resolve
objMessage.Send showDialog:=False
objSession.Logoff
write_error:
Dim datestr, timestr, err1, err2 As String
Open "d:\Compass\CDC\Logs\VBA\BCAVBACDO Test Email Report log.txt" For Append As #1
datestr = Date
timestr = Time
err1 = Err.Number
err2 = Err.Description
Print #1, datestr; timestr; err1; err2
Close #1
End Sub
I belive that the session has not been initiated correctly as the error description is ‘MAPI_E_LOGON_FAILED’. Please create a session as explained here
Also from MS site:
[Ed- Wrapped Code in BBCode to keep formatting]
Here is the macro. I’ll post it in Samples. Thanks for trying to help me.
Private Sub Document_AfterRefresh()
On Error GoTo write_error
Dim TargetFile As String, DocName As String, sText As String, rText As String
Dim errText, datestr, timestr, err1, err2 As String
Dim InputString As String, FileNum As Integer, FileNum2 As Integer
MsgBox ("1")
DocName = "c:\Compass\EmailArchive\HZN-B2B_Trending_Central.htm"
ActiveDocument.Reports(6).ExportAsHtml (DocName)
SourceFile = "c:\Compass\EmailArchive\HZN-B2B_Trending_Central.htm"
TargetFile = "c:\Compass\EmailArchive\HZN-B2B_Trending_Central.html"
If Dir(SourceFile) = "" Then
Open "c:\Compass\CDC\Logs\VBA\HZN-B2B_Trending_log.txt" For Append As #1
datestr = Date
timestr = Time
err1 = Err.Number
err2 = Err.Description
Print #1, "File "; SourceFile; "DNE"; datestr; timestr; err1; err2
Close #1
Exit Sub
Else
MsgBox ("Source file exists")
End If
MsgBox ("2")
If Dir(TargetFile) <> "" Then
On Error Resume Next
Kill TargetFile
On Error GoTo write_error
If Dir(TargetFile) <> "" Then
MsgBox TargetFile & " already open, close and delete / rename the file and try again.", vbCritical
Exit Sub
End If
End If
'MsgBox ("3")
sText = "IMG SRC ="""
rText = "IMG SRC =""http://10.4.4.206/"
MsgBox (sText)
MsgBox (rText)
FileNum = FreeFile ' next free filenumber
'MsgBox ("3.2")
Open SourceFile For Input As FileNum
'MsgBox ("3.3")
FileNum2 = FreeFile ' next free filenumber
'MsgBox ("3.4")
Open TargetFile For Output As FileNum2
MsgBox ("3.5")
While Not EOF(FileNum)
Line Input #FileNum, InputString ' read a line from the textfile
MsgBox (InputString)
If sText <> "" Then
ReplaceTextInString InputString, sText, rText
End If
MsgBox (InputString)
Print #FileNum2, InputString
Wend
Close #FileNum
Close #FileNum2
MsgBox ("5")
hFile = FreeFile
Open "c:\Compass\MSShell\HZN-B2B_T_VBAEMAIL.bat" For Output Access Write As hFile
Print #hFile, "Blat c:\Compass\EmailArchive\HZN-B2B_Trending_Central.html -subject ""HZN B2B Treanding report has been updated"" -to mike.sainz@cingular.com -f BUSINESS.OBJECTS.COMPASS@cingular.com -html"
Close hFile
MsgBox ("6")
Shell ("c:\Compass\MSShell\HZN-B2B_T_VBAEMAIL.bat")
Exit Sub
write_error:
errText = "Error" & Err.Number & "-" & Err.Description
MsgBox (errText)
Open "c:\Compass\CDC\Logs\VBA\HZN-B2B_Trending_log.txt" For Append As #1
datestr = Date
timestr = Time
err1 = Err.Number
err2 = Err.Description
Print #1, datestr; timestr; err1; err2
Close #1
End Sub
Private Sub ReplaceTextInString(SourceString As String, SearchString As String, ReplaceString As String)
Dim p As Integer, NewString As String
Do
p = InStr(p + 1, UCase(SourceString), UCase(SearchString))
If p > 0 Then ' replace SearchString with ReplaceString
NewString = ""
If p > 1 Then NewString = Mid(SourceString, 1, p - 1)
NewString = NewString + ReplaceString
NewString = NewString + Mid(SourceString, p + Len(SearchString), Len(SourceString))
p = p + Len(ReplaceString) - 1
SourceString = NewString
End If
If p >= Len(NewString) Then p = 0
Loop Until p = 0
End Sub
Sub ReadLineFromPrintedTextFile()
Dim InputString As String, FileNum As Integer
FileNum = FreeFile ' next free filenumber
Open "C:\report.txt" For Input As #FileNum
While Not EOF(FileNum)
Line Input #FileNum, InputString ' read a line from the textfile
MsgBox (InputString)
Wend
Close #FileNum
End Sub
I too was having trouble because I did not have the cdo 1.21 library installed on my pc. I had our systems people re-install outlook 2000 on my pc and they had to choose to install the cdo 1.21 library from the disk. I am now able to see the cdo 1.21 library in Visual basic.