Home Outlook.mailitem when defining it doesn't want to define?
Reply: 0

Outlook.mailitem when defining it doesn't want to define?

Casey M
1#
Casey M Published in 2018-01-12 15:53:12Z

Code is erroring out at Dim olmail as Outlook.MailItem.
says usertype not defined.... but that is where I am defining it.

fyi running it from excel 2016

short version of what is happening I'm using this in an older version on the workbook I'm working with. The sub used to be private now it's standard. Tried modifying it either way doesn't change the error. Another developer made some userform changes and other changes in the workbook... not sure what they are and plugged in old code into the same command button as old version. I've checked name... etc... , but it errors here where it didn't error on old version...?

I appreciate any help hopefully it just jumps right out at someone. :)

 Dim abc As String
 Dim emailbody As String
 Dim outlookOBJ As Object
' Dim mItem As Object


Dim myPath As Variant
   'Dim olmail As Object   ' when changing to an object it works, but can't open    the file and attachment doesn't attach
  Dim olmail As Outlook.MailItem  ' errors here User-defined Type not defined, but I am defining it here...?

Set outlookOBJ = CreateObject("Outlook.Application")
' Set olmail = outlookOBJ.CreateItem(0)
Set olmail = outlookOBJ.CreateItem(olMailItem)

Dim strPrompt As String, strname As String
Dim sreplace As String, mychar As Variant, strdate As String

With olmail
olmail.To = "123@gmail.com"
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.407965 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO