/// <exception cref="MailBadLengthOrFormat">Length is lower than 1 or higher than 20</exception> /// <exception cref="HttpRequestException">Error in sending requests, contains inner exception</exception> /// <param name="length">Length of mail base 1 - 20 characters</param> public void SetMail(int length = 20) { if (length < 1 || length > 20) { throw new MailInvalidLengthOrFormat(); } MailAdress = new MailAddress($"{RandomPart.GenerateString(length)}@{Domain}"); setMailBase(); }
/// <exception cref="MailBadLengthOrFormat">Length is lower than 1 or higher than 20</exception> /// <exception cref="HttpRequestException">Error in sending requests, contains inner exception</exception> /// <param name="oldMails">List of previously generated mails to make shure that evry mail is generated only once</param> /// <param name="length">Length of mail base 1 - 20 characters</param> public void SetMail(Ovh[] oldMails, int length = 16) { if (length < 1 || length > 20) { throw new MailInvalidLengthOrFormat(); } string buf = RandomPart.GenerateString(length); foreach (Ovh acc in oldMails) { if (buf == acc.MailAdress.User) { throw new MailIsAlreadyTaken(); } } MailAdress = new MailAddress($"{buf}@{Domain}"); setMailBase(); }