Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook.MailItem Class Invalid

Status
Not open for further replies.

faeryfyrre

Programmer
Aug 4, 2003
198
AU
Hi,
I am trying to store an outlook message (saved from outlook as a *.msg file) in an OLEobject field. I am using a Bound Object Frame as the bound control on my form. I am getting the Following Error message when i run the code below. Could someone please point me in the right direction.

=================================================
The class argument in the CreateObject function of the Visual Basic procedure you're trying to run in Invalid.


try one of the following:
* Make sure the file is installed on your computer and that you used the correct filename
* Check the OLE server's documentation for information about the syntax to use when specifying an OLE object's data.
=================================================


Code:
Private Sub cmd_Set_Y_MOREmail_Click()
On Error GoTo Err_cmd_Set_Y_MOREmail_Click
  
  'Check the OLE control to see whether there is already an email
  Dim tmpole As BoundObjectFrame, x As Variant, msg As String
  Dim response As Variant, filter As String, docName As Variant
  Dim lngFlags As Long

  Set tmpole = Me.Y_GateOpener_MOREmailProof
  
  If Not IsNull(tmpole.Value) Then
    Debug.Print tmpole.Class
    msg = "Do you wish to replace the existing Email?"
    response = MsgBox(msg, vbYesNo)
    If response = vbNo Then Exit Sub
  End If
  
  filter = ahtAddFilterItem(filter, "Outlook Message (*.msg)", "*.msg")
  filter = ahtAddFilterItem(filter, "All Files (*.*)", "*.*")
  
  docName = ahtCommonFileOpenSave(InitialDir:="C:\", _
        filter:=filter, FilterIndex:=1, Flags:=lngFlags, _
        DialogTitle:="Hello! Open Me!", OpenFile:=True)
        
  If Nz(docName) = "" Then
    Exit Sub
  End If
  
  tmpole.Class = "Outlook.MailItem"  ' Set class name.
  tmpole.OLETypeAllowed = acOLEEmbedded ' Specify type of object.
  tmpole.SourceDoc = docName ' Specify source file.

[COLOR=red]This is where the S#!T hits the fan, When i try to actually create the embedded object i am told that the class "Outlook.MailItem" is invalid [/color]
  tmpole.Action = acOLECreateEmbed ' Create linked object.

  tmpole.SizeMode = acOLESizeClip ' Adjust control size.
  
Exit_cmd_Set_Y_MOREmail_Click:
  Exit Sub
  
Err_cmd_Set_Y_MOREmail_Click:
  MsgBox "cmd_Set_Y_MOREmail_Click" & vbCrLf & Err.Description
  Resume Exit_cmd_Set_Y_MOREmail_Click
End Sub

Alec Doughty
Doughty Consulting P/L

"Life's a competition. Play hard, but play fair"
 
try this:
tmpole.Class = "Package"
tmpole.SourceDoc = docName
tmpole.Action = acOLECreateEmbed
tmpole.UpdateOptions = acOLEUpdateManual
tmpole.SizeMode = acOLESizeClip
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top