User-Defined type not defined error (MAPI.Session) 
Author Message
 User-Defined type not defined error (MAPI.Session)

Hello I am trying to open the "Select names" dialog box through a
small VB application.  I found the following code on the NG, but
everytime I run it I get an error that pops up saying "User-Defined
type not defined error"
When I hit the debug it higlights this line:
Dim oSession As MAPI.Session

Thanks in advance

Private Sub btn_Bcc_Click()

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Original Code by Ken Slovak                                      '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim oSession As MAPI.Session
Dim oRecipients As MAPI.Recipients
Dim oMessage As MAPI.Message
Dim itmMail As Outlook.MailItem
Dim olRecipients As Outlook.Recipients
Dim ns As Outlook.NameSpace
Dim fld As Outlook.MAPIFolder
Dim strEntry As String
Dim strStore As String
Dim ol As Outlook.Application

' Create a MAPI session
Set oSession = Application.CreateObject("MAPI.Session")
'logon using a shared session
oSession.Logon "", "", False, False
Set oRecipients = oSession.AddressBook

Set oMessage = oSession.Inbox.Messages.Add
Set oMessage.Recipients = oRecipients
oMessage.Subject = "Test"
oMessage.Update
strStore = oMessage.StoreID
strEntry = oMessage.ID
oSession.Logoff

Set ol = CreateObject("Outlook.Application")
Set ns = ol.GetNamespace("MAPI")
Set itmMail = ns.GetItemFromID(strEntry, strStore)
itmMail.Display
Set oSession = Nothing

End Sub



Mon, 02 Aug 2004 02:16:11 GMT  
 User-Defined type not defined error (MAPI.Session)
Do you have CDO installed?  Its not installed by default in Outlook 2000 and
higher.

--
Patricia Cardoza
Outlook MVP
www.cardozasolutions.com

~Please post all replies to the newsgroup~

Quote:
> Hello I am trying to open the "Select names" dialog box through a
> small VB application.  I found the following code on the NG, but
> everytime I run it I get an error that pops up saying "User-Defined
> type not defined error"
> When I hit the debug it higlights this line:
> Dim oSession As MAPI.Session

> Thanks in advance

> Private Sub btn_Bcc_Click()

> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> ' Original Code by Ken Slovak                                      '
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

> Dim oSession As MAPI.Session
> Dim oRecipients As MAPI.Recipients
> Dim oMessage As MAPI.Message
> Dim itmMail As Outlook.MailItem
> Dim olRecipients As Outlook.Recipients
> Dim ns As Outlook.NameSpace
> Dim fld As Outlook.MAPIFolder
> Dim strEntry As String
> Dim strStore As String
> Dim ol As Outlook.Application

> ' Create a MAPI session
> Set oSession = Application.CreateObject("MAPI.Session")
> 'logon using a shared session
> oSession.Logon "", "", False, False
> Set oRecipients = oSession.AddressBook

> Set oMessage = oSession.Inbox.Messages.Add
> Set oMessage.Recipients = oRecipients
> oMessage.Subject = "Test"
> oMessage.Update
> strStore = oMessage.StoreID
> strEntry = oMessage.ID
> oSession.Logoff

> Set ol = CreateObject("Outlook.Application")
> Set ns = ol.GetNamespace("MAPI")
> Set itmMail = ns.GetItemFromID(strEntry, strStore)
> itmMail.Display
> Set oSession = Nothing

> End Sub



Mon, 02 Aug 2004 02:49:59 GMT  
 User-Defined type not defined error (MAPI.Session)
Yes I Installed CDO for Outlook. I also thought I had installed the
CDO 1.2 Library referance in my project but I must have removed it
when it didn't work on something else I put it back in and I get the
following error now:
Runtime error 13
Type mismatch

on the following line of code:
Set oSession = Application.CreateObject("MAPI.Session")


Quote:
> Do you have CDO installed?  Its not installed by default in Outlook 2000 and
> higher.

> --
> Patricia Cardoza
> Outlook MVP
> www.cardozasolutions.com

> ~Please post all replies to the newsgroup~


> > Hello I am trying to open the "Select names" dialog box through a
> > small VB application.  I found the following code on the NG, but
> > everytime I run it I get an error that pops up saying "User-Defined
> > type not defined error"
> > When I hit the debug it higlights this line:
> > Dim oSession As MAPI.Session

> > Thanks in advance

> > Private Sub btn_Bcc_Click()

> > ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> > ' Original Code by Ken Slovak                                      '
> > ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

> > Dim oSession As MAPI.Session
> > Dim oRecipients As MAPI.Recipients
> > Dim oMessage As MAPI.Message
> > Dim itmMail As Outlook.MailItem
> > Dim olRecipients As Outlook.Recipients
> > Dim ns As Outlook.NameSpace
> > Dim fld As Outlook.MAPIFolder
> > Dim strEntry As String
> > Dim strStore As String
> > Dim ol As Outlook.Application

> > ' Create a MAPI session
> > Set oSession = Application.CreateObject("MAPI.Session")
> > 'logon using a shared session
> > oSession.Logon "", "", False, False
> > Set oRecipients = oSession.AddressBook

> > Set oMessage = oSession.Inbox.Messages.Add
> > Set oMessage.Recipients = oRecipients
> > oMessage.Subject = "Test"
> > oMessage.Update
> > strStore = oMessage.StoreID
> > strEntry = oMessage.ID
> > oSession.Logoff

> > Set ol = CreateObject("Outlook.Application")
> > Set ns = ol.GetNamespace("MAPI")
> > Set itmMail = ns.GetItemFromID(strEntry, strStore)
> > itmMail.Display
> > Set oSession = Nothing

> > End Sub



Mon, 02 Aug 2004 07:22:46 GMT  
 User-Defined type not defined error (MAPI.Session)
Try it without the Application before CreateObject. I never use that
formulation myself.

    Set oSession = CreateObject("MAPI.Session")

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Quote:
> Yes I Installed CDO for Outlook. I also thought I had installed the
> CDO 1.2 Library referance in my project but I must have removed it
> when it didn't work on something else I put it back in and I get the
> following error now:
> Runtime error 13
> Type mismatch

> on the following line of code:
> Set oSession = Application.CreateObject("MAPI.Session")



Tue, 03 Aug 2004 00:51:14 GMT  
 User-Defined type not defined error (MAPI.Session)
Thank you Ken, worked perfectly!


Quote:
> Try it without the Application before CreateObject. I never use that
> formulation myself.

>     Set oSession = CreateObject("MAPI.Session")

> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Lead Author, Beginning VB 6 Application Development, Wrox Press
> Attachment Options
> http://www.slovaktech.com/attachmentoptions.htm
> Extended Reminders
> http://www.slovaktech.com/extendedreminders.htm



> > Yes I Installed CDO for Outlook. I also thought I had installed the
> > CDO 1.2 Library referance in my project but I must have removed it
> > when it didn't work on something else I put it back in and I get the
> > following error now:
> > Runtime error 13
> > Type mismatch

> > on the following line of code:
> > Set oSession = Application.CreateObject("MAPI.Session")



Wed, 04 Aug 2004 04:57:30 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. User-Defined type not defined error (MAPI.Session)

2. Compile Error: User-defined type not defined

3. Compile Error - User defined type not defined

4. Compile Error - User-Defined type not defined

5. Compile error: User-defined data type not defined!

6. user defined type not defined error help please

7. ComctlLib; compiler error: User-defined type not defined

8. Help!!-NEWBIE - Application Wizard -(WROX BOOK) Error- User defined type not defined

9. Error: User-defined type not defined

10. Compile error: User-defined type not defined

11. Help!!-NEWBIE - Application Wizard -(WROX BOOK) Error- User defined type not defined

12. Compiler Error: User-defined type not defined

 

 
Powered by phpBB® Forum Software