Group:  Microsoft Access ยป microsoft.public.access
Thread: Compile error? Help!

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Compile error? Help!
"Jay" <zeugma[ at ]toucanspam.com.com> 26.09.2006 20:53:48
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


Re: Compile error? Help!
"Pieter Wijnen" <it.isi.llegal.to.send.unsollicited.mail.wijnen.nospam.please[ at ]online.replace.with.norway> 27.09.2006 00:06:42
you need to add a reference to outlook
(any) module -> references -> add
--
Pieter Wijnen

My feeble Access pages (good links though)
http://www.thuleeng.com/access
When all else fail try:
http://www.mvps.org/access
http://www.granite.ab.ca/
http://allenbrowne.com/
http://www.lebans.com/

"Jay" <zeugma[ at ]toucanspam.com.com> wrote in message
news:%23Wd6s3a4GHA.4352[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text]
> 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
>
>

--------------------------------------------------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 4868 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net