如今,你不能没有收到一堆垃圾邮件后立即公布一个电子邮件地址的任何地方。这些垃圾邮件的网络抓取工具只搜索innbsp;每一个网站找什么都类似于电子邮件地址。
我经常看到人们使用不同的变化,写他们喜欢quot电子邮件; MYNAME mydomain.comquot;或quot; MYDOMAIN点comquot MYNAME;
我不认为这涵盖了... ... { BR}最好的办法,在我看来,是创建一个电子邮件地址,而不是书面的形象。 (这是什么FACEBOOK以及。)
我开始工作在一个基于用户的站点,用户的电子邮件将显示整个网站。所以我创建了一个类,将动态生成对我的电子邮件地址的图像,所以我宝贵的用户将无法如此脆弱,这里所有的垃圾邮件有
。// Members //
private int _emailFontSize = 8;
private string _emailFontFamily = "Verdana";
private Brush _emailBackgroundColor = Brushes.White;
private Brush _emailFontColor = Brushes.Navy;
// Properties //
// I cut this out, just for convenience //
// Methods //
public void CreateEmailImage(string email)
{
// create the font object
Font myFont = new Font(_emailFontFamily, _emailFontSize);
// create the image object
Bitmap emailImage = new Bitmap((int)(myFont.SizeInPoints * email.Length),
myFont.Height);
Graphics imgGraphics = Graphics.FromImage((Image)emailImage);
imgGraphics.FillRectangle(_emailBackgroundColor,
new Rectangle(new Point(0, 0), emailImage.Size));
imgGraphics.DrawString(email, myFont, _emailFontColor, new PointF(0, 0));
// measure the actual size of the email string
SizeF stringSize = imgGraphics.MeasureString(email, myFont);
// crop the image we created
Bitmap finalImage = CropImage(emailImage,
new Rectangle(new Point(0, 0), new Size((int)stringSize.Width,
(int)stringSize.Height)));
// save the image to a local file
finalImage.Save(email + ".gif", ImageFormat.Gif);
}
private Bitmap CropImage(Image imgCrop, Rectangle cropArea)
{
Bitmap bmpImage = new Bitmap(cropArea.Width, cropArea.Height - 1);
Graphics bmpG = Graphics.FromImage(bmpImage);
bmpG.DrawImage(imgCrop, new Point(0, 0));
return bmpImage;
}
}
我可能会做出一些变化,我的网站上使用前:我不认为它的智能文件实际的电子邮件地址的名称。我可能会产生一些独特的ID,但是从内置的用户名。我还没决定,如果我想的形象是一个链接到用户联系。如果是这样的话,那么我必须为每个用户创建一个唯一的ID,并都具有独特的ID sonbsp该网页的链接导致;我可以识别用户的联系。我可能会添加一个简单的缓存机制,从而创建一个文件夹中存储的所有图像,然后检查它是否存在,然后再创建一个新的每次。
享受! :)
{S0}