P
PsyberFox
Hi there,
I am getting an error stating User-defined type not defined when running the
following code. I have activated References for Microsoft Office 12.0 Object
Library as well as Microsoft Access 12.0 Object Library. This is in Access
2007, and off a command button called cmd_Email
Sub cmd_Email_Click()
Dim objOutlook As Outlook.Application
Dim objOutlookMessage As Outlook.MailItem
Dim objOutlookRecipient As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMessage
' Add the To recipient(s) to the message.
Set objOutlookRecipient = .Recipients.Add("(e-mail address removed)")
objOutlookRecipient.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecipient = .Recipients.Add("(e-mail address removed)")
objOutlookRecipient.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "Test"
.Body = PropertyRef & vbCrLf _
& PropertyType & vbCrLf _
& PropertyCategory & vbCrLf _
& Description & vbCrLf _
& Address1 & vbCrLf _
& Address2 & vbCrLf _
& Address3 & vbCrLf _
& Active
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
' If Not IsMissing(AttachmentPath) Then
' Set objOutlookAttach = .Attachments.Add(AttachmentPath)
' End If
' Resolve each Recipient's name.
For Each objOutlookRecipient In .Recipients
objOutlookRecipient.Resolve
If Not objOutlookRecipient.Resolve Then
objOutlookMessage.Display
End If
Next
.Send
End With
Set objOutlookMessage = Nothing
Set objOutlook = Nothing
End Sub
Please help! Thank you very mooch!
I am getting an error stating User-defined type not defined when running the
following code. I have activated References for Microsoft Office 12.0 Object
Library as well as Microsoft Access 12.0 Object Library. This is in Access
2007, and off a command button called cmd_Email
Sub cmd_Email_Click()
Dim objOutlook As Outlook.Application
Dim objOutlookMessage As Outlook.MailItem
Dim objOutlookRecipient As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMessage
' Add the To recipient(s) to the message.
Set objOutlookRecipient = .Recipients.Add("(e-mail address removed)")
objOutlookRecipient.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecipient = .Recipients.Add("(e-mail address removed)")
objOutlookRecipient.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "Test"
.Body = PropertyRef & vbCrLf _
& PropertyType & vbCrLf _
& PropertyCategory & vbCrLf _
& Description & vbCrLf _
& Address1 & vbCrLf _
& Address2 & vbCrLf _
& Address3 & vbCrLf _
& Active
.Importance = olImportanceHigh 'High importance
' Add attachments to the message.
' If Not IsMissing(AttachmentPath) Then
' Set objOutlookAttach = .Attachments.Add(AttachmentPath)
' End If
' Resolve each Recipient's name.
For Each objOutlookRecipient In .Recipients
objOutlookRecipient.Resolve
If Not objOutlookRecipient.Resolve Then
objOutlookMessage.Display
End If
Next
.Send
End With
Set objOutlookMessage = Nothing
Set objOutlook = Nothing
End Sub
Please help! Thank you very mooch!