J
Jay
I'm stumbling my way around trying to automate email from a database. I
cribbed the code below from an example DB I downloaded. The code works
perfectly in the original DB but the exact same code gives me a Compile
error 'User-defined type not defined' ? The debugger highlights the
following line:
appOutLook As Outlook.Application
The whole code is:
Private Sub cboOpenOutlook_Click()
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.BodyFormat = olFormatRichText
.To = Me.txtEmailAddress
.Subject = Me.txtEmailSubject
.HTMLBody = Me.txtMessageText
'.DeleteAfterSubmit = True 'This would let Outlook
send th note without storing it in your sent bin
.Display
End With
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message
is: " & Err.Description
Resume Error_out
Error_out:
End Sub
If anyone could help me with why the code works in one DB but not in another
I would be extremely grateful. I'm a VBA novice and have just been
stumbling my way around & think figuring this out is just out of my
skill-set at the moment.
Many thanks,
Jason
cribbed the code below from an example DB I downloaded. The code works
perfectly in the original DB but the exact same code gives me a Compile
error 'User-defined type not defined' ? The debugger highlights the
following line:
appOutLook As Outlook.Application
The whole code is:
Private Sub cboOpenOutlook_Click()
Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.BodyFormat = olFormatRichText
.To = Me.txtEmailAddress
.Subject = Me.txtEmailSubject
.HTMLBody = Me.txtMessageText
'.DeleteAfterSubmit = True 'This would let Outlook
send th note without storing it in your sent bin
.Display
End With
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message
is: " & Err.Description
Resume Error_out
Error_out:
End Sub
If anyone could help me with why the code works in one DB but not in another
I would be extremely grateful. I'm a VBA novice and have just been
stumbling my way around & think figuring this out is just out of my
skill-set at the moment.
Many thanks,
Jason