Hi Everyone. I am having a tough time getting an outlook email to display after I click the button. Can someone please take a look at the code below? I am getting an error message that says, "user defined typed not defined" when I get to the line that says, "Dim olApp As Outlook.Application"
-------------------------------------
Private Sub Command13_Click()
'Email code starts here
'Reference the Outlook Application
Dim olApp As Outlook.Application
'The NameSpace object allows you to erference folders
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
'Create a reference to the mail item you will use to send your email
Dim olMailItem As Outlook.MailItem
'Create the Outlook object
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olFolder = olNS.GetDefaultFolder(olFolderInbox)
Set olMailItem = olFolder.Items.Add("IPM.Note")
'Create the body of the message
strBodyText = "Testing Email Function"
'Update the new mail object with your data
.Subject = "Email Test"
.To = email@email.com
.CC = email@email.com
.Body = strBodyText
.Display
End With
'Release all of your object variables
Set olMailItem = Nothing
Set olFolder = Nothing
Set olNS = Nothing
Set olApp = Nothing
End Sub
-------------------------------------------------------------------------
Thanks to anyone who can help me out on this