Options

Email address

tobarichtobarich Member Posts: 33
Hi: I have a job which run a codeunit for sending emails. The problem is that sometimes users write wrong address and the job fails.
Does anyone knows about a code to check the address?

Thanks

Comments

  • Options
    djswimdjswim Member Posts: 277
    It depends on how complex you want to make it... do you just want to make sure that the address contains *@*.*?
    "OMG ALL MY DATA IS GONE"
    "Show All..."
    "Oh..."
  • Options
    garakgarak Member Posts: 3,263
    edited 2008-09-19
    The mailadressformat is wrong or the address not exist :?:

    If the format is wrong, u must only check if there is a "@" and before the @ are letters (the local part) and after the @ are letters (the domain part). Both parts are split by the @.

    The local part could only have letters or numbers and some chars like: A-Za-z0-9.!#$%&'*+-/=?^_`{|}~ (so here you can check the local part).

    For the second part, the domain part exist also rules (see Domain Name System [DNS]). so check if after the @ is an "." (dot) and after the dot min. 2-4 letters. Then it could be an correct mailaddress (format)

    EDIT
    if you need mor infos:

    The whole definition of a EMail Addressformat you can read in "RFC 2822, 2606 2821" and some others.

    Regards
    Do you make it right, it works too!
  • Options
    SavatageSavatage Member Posts: 7,142
    We Check On Entry Of The Email Address

    E-Mail - OnValidate()
    IF "E-Mail" = xRec."E-Mail" THEN   EXIT;
    "E-Mail" := LOWERCASE("E-Mail");
    IF ("E-Mail" <> '') AND (STRPOS("E-Mail",'@') = 0) THEN
      ERROR('@ must exist in E-Mail.');
    IF ("E-Mail" <> '') AND (STRPOS("E-Mail",'.') = 0) THEN
      ERROR('. must exist in E-Mail.');
    
Sign In or Register to comment.