Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create a mailto field in access

Status
Not open for further replies.

JodieK

Instructor
Jul 27, 2001
15
0
0
GB
Can anyone help with creating a mailto field in access? This is the code I have but it doesn't seem to be working access just keeps adding http to the address:

Private Sub Email_AfterUpdate()
If Not IsNull(Me.Email) Or Left(Me.Email, 7) <> &quot;#mailto:&quot; Then
Me.Email = &quot;#mailto:&quot; & Me.Email
End If

Thank you!


 
Hi Jodie,
I'm just guessing here but is the data type a Hyperlink? If so try it as Text.
Giles
 
Hi, you may want to use this function from MS Code Librarian. By cliking a CmdButton you have it all.


Function SendNewMail(frmForm As Form) As Boolean
' This procedure is called from the Click event procedure of
' the Send command button on the NewMailMessage form. It adds
' recipients and attachments to the MailItem and sets various
' additional properties.

Dim objNewMail As MailItem
Dim objRecip As Recipient
Dim strRecipients As String
Dim strAttachments As String
Dim blnResolved As Boolean

On Error GoTo SendMail_Err

DoCmd.Hourglass True

' Use the InitializeOutlook procedure to initialize global
' Application and NameSpace object variables, if necessary.
If golApp Is Nothing Then
If InitializeOutlook = False Then
MsgBox &quot;Unable to initialize Outlook Application &quot; _
& &quot;or NameSpace object variables!&quot;
Exit Function
End If
End If

' Create new MailItem object.
Set objNewMail = golApp.CreateItem(olMailItem)

' Add recipients to MailItem object's Recipients collection.
With objNewMail
.Recipients.Add frmForm!txtTo
If Not IsNull(frmForm!txtCC) Then
If InStr(frmForm!txtCC, &quot;;&quot;) = 0 Then
Set objRecip = .Recipients.Add(frmForm!txtCC)
objRecip.Type = olCC
Else
strRecipients = frmForm!txtCC
' Parse recipients and add them to object's
' Recipients collection.
Do
Set objRecip = _
.Recipients.Add(Left(strRecipients, _
InStr(strRecipients, &quot;;&quot;) - 1))
objRecip.Type = olCC
strRecipients = Trim(Mid(strRecipients, _
InStr(strRecipients, &quot;;&quot;) + 1))
Loop While InStr(strRecipients, &quot;;&quot;) <> 0
If Len(strRecipients) > 0 Then
Set objRecip = .Recipients.Add(strRecipients)
objRecip.Type = olCC
End If
End If
End If

' Let Outlook verify that these are valid recipients.
blnResolved = .Recipients.ResolveAll

' Add attachments to MailItem object's Attachments
' collection.
If Not IsNull(frmForm!txtAttachments) Then
If InStr(frmForm!txtAttachments, &quot;;&quot;) = 0 Then
.Attachments.Add frmForm!txtAttachments
Else
strAttachments = frmForm!txtAttachments
' Parse attachments and add them to the
' Attachments collection.
Do
.Attachments.Add Left(strAttachments, _
InStr(strAttachments, &quot;;&quot;) - 1)
strAttachments = Trim(Mid(strAttachments, _
InStr(strAttachments, &quot;;&quot;) + 1))
Loop While InStr(strAttachments, &quot;;&quot;) <> 0
If Len(strAttachments) > 0 Then .Attachments.Add _
strAttachments
End If
End If

' Set MailItem object's Subject and Body properties.
.Subject = Nz(frmForm!txtSubject, &quot;&quot;)
.Body = Nz(frmForm!txtMessage, &quot;&quot;)

' Set MailItem object's Importance property.
Select Case frmForm!ctlImportance
Case olImportanceHigh
.Importance = olImportanceHigh
Case olImportanceNormal
.Importance = olImportanceNormal
Case olImportanceLow
.Importance = olImportanceLow
End Select

' Send or display MailItem depending on user's choice.
If frmForm!ctlViewMail.Value = 1 Or blnResolved = False Then
.Display
Else
.Send
End If
End With

SendNewMail = True

SendMail_End:
DoCmd.Hourglass False
Exit Function
SendMail_Err:
SendNewMail = False
MsgBox &quot;Error &quot; & Err.Number & vbCrLf & Err.Description
Resume SendMail_End
End Function
-------------------------
Regards
JoaoTL
-------------------------

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top