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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting the Mailto: from an email address

Status
Not open for further replies.

GJP55

Technical User
Joined
Feb 2, 2003
Messages
220
Location
GB
I have a field in a table that stores email addresses (hyperlink data type). I am trying to write what should be very simple code to delete the "mailto" if its there from the front of an email address (it was company policy to do that some months back). I do not seem to be able to make the code stop at an email address that starts with "Mailto:" at the front of it. I have already ran some code that sorts out the acAddress, acSubAddress and acDisplay properties so they open up in exchange properly but am now not sure why I can't get this bit to work.
Code I have been working on is:

Dim stDisplayText As String
Dim rs As DAO.Recordset
Dim i, NoRecs As Integer

Set rs = CurrentDb.OpenRecordset("MyRecs")
rs.MoveLast
NoRecs = rs.RecordCount
rs.MoveFirst

For i = 0 To NoRecs - 1

If Len(rs![e-mail address]) > 0 Then
stDisplayText = HyperlinkPart(rs![e-mail address], acDisplayText)

If stDisplayText like "mailto:*" Then
stDisplaytext = Right$(stDisplayText) - 8
Debug.Print stDisplayText
......code to update table with new display email address
End If

End if
rs.MoveNext
Next
rs.close


Any help much appreciated.
Thanks
 
Try this:

stDisplayText = Replace(stDisplayText,"mailto:","")

Tranman
 
You could also try:

If left(stDisplayText,7) = "mailto:" then
stDisplay = right(stDsiplayText,len(stDisplayText)-7)
end if

Though i have to say that Tranman's looks neater :-)
 
Actually needed both bits of code to make itr work.

Thanks to both
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top