S
stever
I'm a complete novice at any codeing ie: I know nothing so I need a bit
of hand holding
I want to have an outlook e-mail come up or be sent automatically any
time a certain DB has data entered.
I want the action initiated any time the user cliks a button on the
from. That is to send an e-mail to a set of e-mail addresses.
So I have my form up in access add an event button go to build event
and code get the VB editor up and paste in the following code that was
cut from this group.
Save and try the button, nothing happens.
So any help for a complete kluts that does not do this for a living ao
on a regualer bases would be appreciated.
Private ola As Outlook.Application
Private nsp As Outlook.NameSpace
Private mli As Outlook.MailItem
Public Sub SendEmail(varTo As Variant)
Dim mli As Outlook.MailItem
InitOutlook
Set mli = ola.CreateItem(olMailItem)
mli.To = varTo & "(e-mail address removed)"
mli.Subject = "Message for Access Contact"
mli.SenderName = "(e-mail address removed)"
mli.Display
Set mli = Nothing
CleanUpOutlook
End Sub
Public Sub InitOutlook()
' Initialize a session in Outlook
Set ola = New Outlook.Application
' Return a reference to the MAPI layer
Set nsp = ola.GetNamespace("MAPI")
' Let the user logon to Outlook with the
' Outlook Profile dialog box
' and then create a new session.
' The next line is not actioned
' if Outlook already running.
nsp.Logon , , True, False
End Sub
Public Sub CleanUpOutlook()
' Clean up public object references.
Set nsp = Nothing
Set ola = Nothing
End Sub
of hand holding
I want to have an outlook e-mail come up or be sent automatically any
time a certain DB has data entered.
I want the action initiated any time the user cliks a button on the
from. That is to send an e-mail to a set of e-mail addresses.
So I have my form up in access add an event button go to build event
and code get the VB editor up and paste in the following code that was
cut from this group.
Save and try the button, nothing happens.
So any help for a complete kluts that does not do this for a living ao
on a regualer bases would be appreciated.
Private ola As Outlook.Application
Private nsp As Outlook.NameSpace
Private mli As Outlook.MailItem
Public Sub SendEmail(varTo As Variant)
Dim mli As Outlook.MailItem
InitOutlook
Set mli = ola.CreateItem(olMailItem)
mli.To = varTo & "(e-mail address removed)"
mli.Subject = "Message for Access Contact"
mli.SenderName = "(e-mail address removed)"
mli.Display
Set mli = Nothing
CleanUpOutlook
End Sub
Public Sub InitOutlook()
' Initialize a session in Outlook
Set ola = New Outlook.Application
' Return a reference to the MAPI layer
Set nsp = ola.GetNamespace("MAPI")
' Let the user logon to Outlook with the
' Outlook Profile dialog box
' and then create a new session.
' The next line is not actioned
' if Outlook already running.
nsp.Logon , , True, False
End Sub
Public Sub CleanUpOutlook()
' Clean up public object references.
Set nsp = Nothing
Set ola = Nothing
End Sub