PC Review


Reply
Thread Tools Rate Thread

Email problem

 
 
PsyberFox
Guest
Posts: n/a
 
      14th May 2010
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 Removed)")
objOutlookRecipient.Type = olTo

' Add the CC recipient(s) to the message.
Set objOutlookRecipient = .Recipients.Add("(E-Mail 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!

--
The Psyber Fox
http://www.psyberconsulting.co.za
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      14th May 2010
"PsyberFox" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


[snip]

Do you have a reference set to the Microsoft Outlook 12.0 Object Library?
You'll need that if you're going to refer to Outlook-defined data types such
as the above.

As an alternative, you could forego the reference and use late binding by
declaring all the Outlook-defined items as Object. You would also have to
declare the constants olMailItem, olTo, olCC, and olImportanceHigh yourself,
since those are defined by the Outlook object library. But if you don't
mind having the reference to the Outlook library, you don't need to do that.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
 
 
 
PsyberFox
Guest
Posts: n/a
 
      15th May 2010
Hi,

Yes I do have the reference to that object library, but still gives me the
problem.

Can you possible give me more details on the alternative?

Thank you!
W
--
The Psyber Fox
http://www.psyberconsulting.co.za


"Dirk Goldgar" wrote:

> "PsyberFox" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
> [snip]
>
> Do you have a reference set to the Microsoft Outlook 12.0 Object Library?
> You'll need that if you're going to refer to Outlook-defined data types such
> as the above.
>
> As an alternative, you could forego the reference and use late binding by
> declaring all the Outlook-defined items as Object. You would also have to
> declare the constants olMailItem, olTo, olCC, and olImportanceHigh yourself,
> since those are defined by the Outlook object library. But if you don't
> mind having the reference to the Outlook library, you don't need to do that.
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>

 
Reply With Quote
 
PsyberFox
Guest
Posts: n/a
 
      15th May 2010
Hi again,

I have actually resolved the problem by simply using DoCmd.SendObject, so
not to worry. Thank you in any case!

Rgds,
W

--
The Psyber Fox
http://www.psyberconsulting.co.za


"Dirk Goldgar" wrote:

> "PsyberFox" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
> [snip]
>
> Do you have a reference set to the Microsoft Outlook 12.0 Object Library?
> You'll need that if you're going to refer to Outlook-defined data types such
> as the above.
>
> As an alternative, you could forego the reference and use late binding by
> declaring all the Outlook-defined items as Object. You would also have to
> declare the constants olMailItem, olTo, olCC, and olImportanceHigh yourself,
> since those are defined by the Outlook object library. But if you don't
> mind having the reference to the Outlook library, you don't need to do that.
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I convert an email attached to an email back to email ale =?Utf-8?B?dGxlZQ==?= Microsoft Outlook Discussion 0 28th Mar 2006 11:26 PM
Email, Email 2, and Email 3 =?Utf-8?B?ZG1zMg==?= Microsoft Outlook Discussion 1 25th Sep 2005 11:49 PM
Client Table with Email? Click email address to send email? =?Utf-8?B?QnJvb2s=?= Microsoft Access Forms 0 10th Aug 2005 05:06 PM
email form, email, get input, email back Who Cares! Microsoft Access Getting Started 2 10th Sep 2004 01:09 AM
Second Email (email 2) from email message not saving with contact Randy Hayes Microsoft Outlook Contacts 3 5th Feb 2004 10:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:59 PM.