开发者

How can I embed a link button in mail to be sent to Notes clients?

I have to send an email to several hundred users. Each will have a link tailored to the recipient so I need to generate the emails in script/code - I'm no Notes developer so I can't do this in Notes; I'm using C# and I'm pulling the list out of a SQL database.

There are some constraints:

  • The site that the link points to use开发者_运维技巧s Integrated Windows Authentication.
  • The sender wants the link to be a button, rather than text.
  • The vast majority of recipients are running Lotus Notes 7.

I've tried creating an HTML mail but have had problems:

  • If I use a form with a submit button and action that points to the link, Notes tries to use its internal browser which fails (because the site uses Integrated Windows Authentication).

  • If I use an a href tag with an img tag in it, pointing to an image on a webserver, Notes refuses to display the image - i just get the red x box, even though the tags are valid if embedded in a web page.

Anyone know how I can do this?


I finally found a method that works: embedding the image in the email itself. I found the solution here. I'll include the critical stuff here, just in case.

There are three key components to the email: the plain text version, the html version and the image, all consructed as AlternateViews:

string imagePath = @"C:\Work\images\clickhere.jpg";
AlternateView imageView = new AlternateView(imagePath, MediaTypeNames.Image.Jpeg);
imageView.ContentId = "uniqueId";
imageView.TransferEncoding = TransferEncoding.Base64;
     :
//loop to generate the url and send the emails containing
    AlternateView plainTextView = AlternateView.CreateAlternateViewFromString(
        BuildPlainTextMessage(url), null, "text/plain");
    AlternateView htmlView = AlternateView.CreateAlternateViewFromString(
        BuildHtmlMessage(url), null, "text/html");
    //set up MailAddress objects called to and from
        :
    MailMessage mail = new MailMessage(from, to);
    mail.Subject = "ACTION REQUIRED: Do this by then or else";
    mail.AlternateViews.Add(plainTextView);
    mail.AlternateViews.Add(htmlView);
    mail.AlternateViews.Add(imageView);
    //send mail using SmtpClient as normal
        :
//endloop

BuildHtmlMessage(string) and BuildPlainTextMessage(string) just return strings containing the messages. BuildHtmlMessage includes this to display the image in a link to 'url':

sb.AppendLine("<div>");
sb.AppendFormat("<a href=\"{0}\" target=\"_blank\">", url);
sb.Append("<img alt=\"Click here button image\" hspace=0 src=\"cid:uniqueId\" ");
sb.Append("align=baseline border=0 >");
sb.Append("</a>");
sb.AppendLine("</div>");

Hope this is of use to someone else, sometime.


I imagine no matter what link you use (button, text), you're going to run into that same problem where the Notes client launches its internal browser. That's a preference on the Notes client, and it could be different on all machines.

I would first try a standard text link to see if it has the same behavior. Maybe if that does work for some reason, you at least can deliver a workaround.

Regarding the image issue - is the image coming from the server using Windows Authentication? Make sure the image is open to the public and doesn't require authentication to see it (test in Firefox, and if you don't get a password prompt, you're safe)

I hate to say it, but you might have to request users copy a URL from their email to a specific browser. At least you'd know that would work.


I agree with Ken on the preference for the internal browser. The image not displaying - showing a red x - might be a preference also. I don't recall if it was available in R7, but in R8 there is a preference to not show remote images automatically. It is a security feature. It could also be a proxy issue - if they would have to login to their internet proxy server to get to the internet, and your image is on the internet...


There is also this but it fires off a security warning to the user with my Notes config:

<input type='button'
       onclick=document.location.href='http://server/path'; 
       value='Click here' 
       id='buttonID' class='button' 
       xstyle='background-color:red;color:white;'/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜