What SQL Server DataType Should I Store an Email MessageId As?

49 Views Asked by At

I'm writing a feature that processes inbound/outbound emails and stores them. One of the most important pieces that I need to store is the Message-Id that's in the header of all standard-compliant emails (from what I understand).

I was going to store the entire Message-Id in a field and index on it, but as I started digging into that, it seems to be the wrong approach. I plan on splitting the Message-Id at the @ sign and storing each piece in a MessageIdLocalPart and MessageIdDomain respectively, then index on the local part.

I've read where the max length for the local part of an email address is 64 characters, and the max for the domain is 255. Now, these max lengths seem to be for email addresses, and I don't see any max lengths in the standard for Message-Id, so I'm not sure that the same restriction applies.

I understand that, as always, there will be non-compliant emails that come through. I'm just going to omit those. I'm working with compliant only emails.

So, instead of storing the local part and domain pieces as VARCHAR(MAX), is there a better limit and/or data type that I should be using?

0

There are 0 best solutions below