S
Steven M. Britton
I have a mod that I use all the time in one of my
databases I imported it into another database to use and
now when I call it it says User-defined type not defined.
It points to the "Dims" at that top of the code, if I
remove all of the Dims it will run the code, but doesn't
function properly. I don't understand why it works for
one database and not the other when it is the excat same
code????
-Steve
Sub SendMessageHeathlyTips(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add
("(e-mail address removed)")
objOutlookRecip.Type = olTo
' Set the Subject, Body, and Importance of the
message.
.Subject = "Daily Shipment File"
.Body = "Here is the file you requested." & vbCrLf &
vbCrLf
.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 objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
databases I imported it into another database to use and
now when I call it it says User-defined type not defined.
It points to the "Dims" at that top of the code, if I
remove all of the Dims it will run the code, but doesn't
function properly. I don't understand why it works for
one database and not the other when it is the excat same
code????
-Steve
Sub SendMessageHeathlyTips(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add
("(e-mail address removed)")
objOutlookRecip.Type = olTo
' Set the Subject, Body, and Importance of the
message.
.Subject = "Daily Shipment File"
.Body = "Here is the file you requested." & vbCrLf &
vbCrLf
.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 objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub