Then there's something wrong about your Outlook project reference, or the
Outlook PIA's aren't installed correctly, or there's something wrong with
your installation of Visual Studio.
Try removing the Outlook reference and then re-adding it, making sure you
are taking the reference from the COM tab and that the PIA is installed in
the GAC.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"fniles" wrote in message
...
Both machines actually has Outlook 2003, but in the new machine I can not
see "Outlook" when I do "dim x as new ....", even though I already select
"Microsoft Outlook 11.0 Object Library"
This is the codes that I use to send email in VB.NET 2005:
Public Class OutlookMail
Public Function startOutlook(ByVal toVal As String, ByVal subjectVal As
String, ByVal bodyVal As String)
'Return a reference to the MAPI layer
Dim ol As New Outlook.Application() -- in the new machine this
gives the error "Type 'Outlook.application' is not defined
Dim ns As Outlook.NameSpace -- in the new machine this gives the
error "Type 'Outlook.NameSpace' is not defined
Dim fdMail As Outlook.MAPIFolder -- in the new machine this gives
the error "Type 'Outlook.MAPIFolder' is not defined
ns = ol.GetNamespace("MAPI")
'Logs on the user
'Profile: This is a string value that indicates what MAPI profile
to use for logging on. Leave blank if using the currently logged on user,
or set to an empty string ("") if you wish to use the default Outlook
Profile.
'Password: The password for the indicated profile. Leave blank if
using the currently logged on user, or set to an empty string ("") if you
wish to use the default Outlook Profile password.
'ShowDialog: Set to True to display the Outlook Profile dialog box.
'NewSession: Set to True to start a new session. Set to False to
use the current session.
ns.Logon(, , True, True)
'create a new MailItem object
Dim newMail As Outlook.MailItem -- in the new machine this gives
the error "Type 'Outlook.MailItem' is not defined
'gets defaultfolder for my Outlook Outbox
fdMail =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFol derOutbox) -- in the
new machine this gives the error "Name 'Outlook' is not declared
'assign values to the newMail MailItem
newMail = fdMail.Items.Add(Outlook.OlItems.olMailItem) -- in the
new machine this gives the error "Name 'Outlook' is not declared
newMail.Subject = subjectVal
newMail.Body = bodyVal
newMail.To = toVal
newMail.SaveSentMessageFolder = fdMail
'adds it to the draft box
'newMail.Save()
'adds it to the outbox
newMail.Send()
End Function