E-Mail

  • Thread starter Thread starter Ken Yanko
  • Start date Start date
K

Ken Yanko

Excuse me for not finding this newsgroup sooner as the question i'm about to
ask has probnibly been asked 1,000 times before. How do i format a textbox
to accept an e-mail address where when the user clicks on the textbox, a new
e-mail is generated?

Thanks Ken
 
Ken said:
Excuse me for not finding this newsgroup sooner as the question i'm about to
ask has probnibly been asked 1,000 times before. How do i format a textbox
to accept an e-mail address where when the user clicks on the textbox, a new
e-mail is generated?

Thanks Ken


in the textbox type mailto:youremailaddress then in Properties/Format select
Yes for Is Hyperlink.
 
Sounds easy enough. Thank you:)

StevenR via AccessMonster.com said:
in the textbox type mailto:youremailaddress then in Properties/Format
select
Yes for Is Hyperlink.
 
OK. I tried it. Perhaps i was unclear in my question. Let me try again.

I have a table named Employees where information about an employee is
stored. In this table i have a field called EMailAddress. I then have a
Form called EmployeesForm linked to the Employees table, via a Query named
EmployeesQuery. When a user clickes on the record in the textbox that uses
the EMailAddress field for the Data Control Source, i want an e-mail to be
generated.

Is this possible?
 
in the event (click, enter, etc?) use code to send e-mail. Her is
example code, as a function, which you pass the recipient name(s) and a
string, that uses Outlook:

Function fxSendDBBackupReport(strRecipients As String, strLogInfo) As
Boolean

Dim objOutlookApp As New Outlook.Application
Dim objOutlookMail As Outlook.MailItem
Dim objOutlookAttachments As Outlook.Attachments

Set objOutlookApp = CreateObject("Outlook.Application")
Set objOutlookMail = objOutlookApp.CreateItem(olMailItem)

With objOutlookMail
.To = strRecipients
.Subject = "Report - " & Now
.Body = vbCrLf & vbCrLf & strLogInfo & vbCrLf & vbCrLf
.Send
End With

fxSendDBBackupReport = True

Exit Function

'releases resources from outlook and associated components
If Not objOutlookApp Is Nothing Then

objOutlookApp.Quit

If Not objOutlookMail Is Nothing Then
Set objOutlookMail = Nothing
End If

If Not objOutlookAttachments Is Nothing Then
Set objOutlookAttachments = Nothing
End If

Set objOutlookApp = Nothing

End If

fxSendDBBackupReport = False

End Function

It can be modified to accept more variables, e.g., attachment, and
there are other ways to simply send mail using the default mail client;
I will post in another e-mail.
 
From somone elses post:

From: fredg
Date: Sat, Feb 18 2006 1:21 pm

DoCmd.SendObject acSendNoObject, , acFormatTXT, [EmailAddressField], ,
, "Item not returned", "Please return the film you have rented." &
vbNewLine & "There is a late fee of $2.00 per day.", True

Look up the SendObject method in VBA help.
 
I ran across this code that purports to work with everything, but does
not do attachments:

'**Module (space formatting added to make it easier to read):

Public Declare Function ShellExecute Lib "shell32.dll"
Alias "ShellExecuteA"
(ByVal hwnd As Long,
ByVal lpOperation As String,
ByVal lpFile As String,
ByVal lpParameters As String,
ByVal lpDirectory As String,
ByVal nShowCmd As Long)
As Long

'**Code attached to a button:

Dim stext As String

'Hard coded parts of the e-mail, stripped down to the minimum
stext = "mailto:[email protected]?"
stext = stext & "&Subject=" & "Document attached"
stext = stext & "&Body=" & "Please find the document attached"

'Launch default e-mail
Call ShellExecute(hwnd, "open", stext, vbNullString, vbNullString,
SW_SHOWNORMAL)
 
Back
Top