Hello,
I have no knowledge of Visual Basic to be honest; The comment at the end of the code shows where I pinched the code from. All works apart for my first "null" section that I tried to add, if someone could explain why this doesn't work that would be great.
Site wouldn't let me explain issue further as apparently my info was marked as "spam"
Many thanks in advance,
Jordan. -
Private Sub Send_Email_Button_Click()
-
If InStr([E-Mail], "") = Null Then
-
MsgBox "Please Enter a Valid E-mail Address"
-
Exit Sub
-
End If
-
If InStr([E-Mail], "@") = False Then
-
MsgBox "The email address '" & [E-Mail] & "' does not appear to be a valid address"
-
Exit Sub
-
Else
-
Application.FollowHyperlink "Mailto:" & [E-Mail]
-
' https://www.experts-exchange.com/questions/21474709/MAILTO-Function-In-MS-Access.html
-
End If
-
End Sub
-
1 1451
Hi Jordan
Nice to have you join Bytes.
The code that you need is nearly right, what you need is -
If IsNull(E-Mail) Then
-
MsgBox "Please Enter a Valid E-mail Address"
-
Exit Sub
-
End If
-
.....
A more thorough check is this - Public Function IE-MailAddress(ByVal E-Mail As String, _
-
Optional ByRef sReason As String) As Boolean
-
-
'If False is returned, the reason for its failure will be passed back into the optional reason string.
-
'IsValid = IE-MailAddress("karl@karlmoore.com", InvalidReason)
-
'MsgBox "Invalid mail address, the reason given is: " & InvalidReason
-
-
Dim nCharacter As Integer
-
Dim sBuffer As String
-
-
E-Mail = Trim(E-Mail)
-
-
If Len(E-Mail) < 8 Then
-
sReason = "Too short"
-
Exit Function
-
End If
-
-
If LCase(Right(E-Mail, 1)) Like "[a-z]" Then
-
GoTo CheckAt
-
End If
-
sReason = "Illegal character at end" ' Check for '.' etc at end
-
Exit Function
-
-
CheckAt:
-
If InStr(E-Mail, "@") = 0 Then
-
sReason = "Missing the @"
-
Exit Function
-
End If
-
-
If InStr(InStr(E-Mail, "@") + 1, E-Mail, "@") <> 0 Then
-
sReason = "Too many @"
-
Exit Function
-
End If
-
-
If InStr(E-Mail, ".") = 0 Then
-
sReason = "Missing the period"
-
Exit Function
-
End If
-
-
If InStr(E-Mail, "@") = 1 Or InStr(E-Mail, "@") = Len(E-Mail) Or _
-
InStr(E-Mail, ".") = 1 Or InStr(E-Mail, ".") = Len(E-Mail) Then
-
sReason = "Invalid format"
-
Exit Function
-
End If
-
-
For nCharacter = 1 To Len(E-Mail)
-
sBuffer = Mid$(E-Mail, nCharacter, 1)
-
If Not (LCase(sBuffer) Like "[a-z]" Or sBuffer = "@" Or _
-
sBuffer = "." Or sBuffer = "-" Or sBuffer = "_" Or IsNumeric(sBuffer)) Then
-
sReason = "Invalid character"
-
Exit Function
-
End If
-
Next nCharacter
-
-
nCharacter = 0
-
-
On Error Resume Next
-
-
sBuffer = Right(E-Mail, 4)
-
If InStr(sBuffer, ".") = 0 Then GoTo TooLong:
-
If Left(sBuffer, 1) = "." Then sBuffer = Right(sBuffer, 3)
-
If Left(Right(sBuffer, 3), 1) = "." Then sBuffer = Right(sBuffer, 2)
-
If Left(Right(sBuffer, 2), 1) = "." Then sBuffer = Right(sBuffer, 1)
-
-
If Len(sBuffer) < 2 Then
-
sReason = "Suffix too short"
-
Exit Function
-
End If
-
-
TooLong:
-
If Len(sBuffer) > 3 Then
-
sReason = "Suffix too long"
-
Exit Function
-
End If
-
-
sReason = Empty ' Dropped through to here, so email address OK
-
IE-MailAddress = True
-
-
End Function
I think if you read it, it is fairly obvious what checks it makes.
Phil
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ronald O. Christian |
last post by:
One of the benefits of coding in php is that a user can't view your
actual php source, only the html it produces. Are there reasonably
simple techniques to avoid having the html scooped also?
...
|
by: Mathew Hill |
last post by:
I am a beginner to the more technical aspects of Microsoft Access
(2000) and was wondering if any one can help. I have 3 buttons on a
form which add, delete and search for a record. However, when I...
|
by: Ray Mitchell |
last post by:
Hello,
I realize that the source code for vsscanf is available from several
sources, such as GNU. However, all such source code I've found so far is
filled with cryptic (to me) #ifdefs, system...
|
by: Nadav |
last post by:
Hi,
Introduction:
************************************************************
I am working on a project that should encrypt PE files ( Portable executable
), this require me to inject some...
|
by: Nevyn Twyll |
last post by:
Is there any way I can use a code-behind event (like a btn_Click event)
to write some javascript into the Response?
I was thinking of using Response.Write() to write the following code into
the...
|
by: bennett |
last post by:
How can I do a loop from 1 to 5, where on line 1 I print 1 space
followed by a button, on line 2 I print 2 spaces followed by a button,
on line 3 I print 3 spaces followed by a button, etc.?
I...
|
by: LP |
last post by:
Hello,
I am trying to use .NET with Excel. I installed Office 2003 and selected
..NET programming suport option, so it installed all those PIA, as MS
sugests. But I can not find a way to destroy...
|
by: djs1979 |
last post by:
Hello,
First time "designer" here. I've mostly used CoffeeCup Vis Designer (a WYSIWYG prog for those unfamiliar with it), and dropped in some code by hand here and there.
My problem is with the...
|
by: maehhheeyy |
last post by:
I want to add a timeout so that when I pull out my gps from my serial
port, it would wait for a bit then loop and then see if it's there. I
also want to add a print statement saying that there is...
|
by: Martin Lang |
last post by:
Hi All,
Thanks for reading this :)
I have a form A that consists of a main form A and a sub form A.
In sub form A, I have a field which I can double click. Then, Main form B opens up with a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |