In C#, I'm sending a mail with an activation link to users after they have registered. However, the link is split over two lines in the mail and thus doesn't work.
I've checked in Visual Studio and the string containing the link looks fine.
I've also tried:
strMessage.Replace("\r", "");
strMessage.Replace("\n", "");
but without success.
Do you have any ideas on how to solve this? I've googled it for hours and can't find the solution...
Thanks!
/J
Is the link longer than 78 chars? Or is there some other text in front of it?
If so, see if you can make it less than 78 and I don't think it'll wrap it. Otherwise, I seem to remember that this could be sort of fixed in some email applications by changing the encoding, possibly the same might work here since I see that there are various Encoding properties of MailMessage.
If you are sending the message as an HTML email, then you could put a link around the email so that it renders on one line, and then have the actual link in brackets with instructions on how to copy and paste it ensuring it's on one line.
Register here
(if the above does not appear in a link, copy the following link into your
browser ensuring that it all goes on one line:
http://www.longaddresshere.com/thatkeepswrapping)
I finally managed to solve this annoying problem. It seems like Outlook was the cause of everything, it divided my LONG html string into two lines. My link just happened to be right at the point of the line break. So I added the sufficient number of characters (with the same color as the background) to make my link start on the second line.
Not the best solution, but it worked in this case...
Related
I have an ASP.NET page that shows stuff (data in tables), does stuff (modifies data) and sometimes sends email about these. It used to work without problems, but recently something broke with the encoding.
The site uses hungarian characters like 'Á', 'Ú' or 'Ő', etc, but this was never a problem before, it displayed them correctly. But recently the emails it sends arrive looking like this:
Sérült tétel státusz változás
Instead of looking like this, as it should:
Sérült tétel státusz változás
The problem is not only with the emails, but sometimes with label texts as well. For example, using this:
Label.Text = "Saját jegyzőkönyveim"
Results in the label showing as:
Saját jegyzőkönyveim
But this only seems to be an issue if label text is set in code-behind. If the label text is set in the .aspx file, then it displays fine. The text content of the emails are also set in the code behind, so I believe the issue must be with the encoding with the .cs file. A while ago I even remember Visual Studio complaining something about the encoding of the files when I saved them once, but I don't remember what it was complaining about. But anyway, I believe it somehow set it to a different encoding or something. It's probably related to a single file, as our other pages still send emails correctly, even though they run under the same web.config, etc.
So what might be the issue? Trying Save As and change encoding there it's already set at UTF-8, so where else might it be changed that causes this? Any help is appreciated, thanks in advance!
Case solved. Turns out the .cs file was encoded in "UTF-8 without signature", while it was supposed to be "UTF-8 with signature".
I usually need to come back to old codes that I hardly remember after some weeks of work with other projects.
I try to write comments concisely, but still codes becomes messy.
Since I work mostly with computer geometry in Visual Studio C#, I was wondering if there is any "easy" way to add image comments rather than text?
I often place such 'documentation' in a project subfolder...
Then use the local FILE:// URI convention to link that image into my code comments or ever XML markup.. with the triple slash convention... which of course shows within intelligence
A comment can certainly link to an image (as a URL for example). But no, you can't embed an image as a comment. Code files are just text, not Word documents.
If the problem is that the code isn't clear and you're relying on comments to understand it, then the solution isn't to add more comments. The solution is to write code more clearly. Give variables semantically meaningful names, extract operations (every very small ones) into semantically meaningful methods. The code itself should tell you exactly what it's doing.
I'm using a program within Powershell called MPTag (Found here: http://powershell.com/cs/media/p/9129.aspx). I want to be able to add a leading zero to track numbers if they are single digits (ie. I want "Track 1" to be "Track 01") but MPTag doesn't seem to accept these leading zeroes (tried putting them in quotes, as a .tostring, etc.).
Is it possible to edit the source code of MPTag (which uses a copy of taglib-sharp.dll) to accept the leading zeroes? Maybe changing a variable to a string rather than an integer?
I've downloaded Telerik JustDecompile and the editing extension Reflexil, and I've found variables that affect the track number, but I don't know what steps need to be taken now to make the changes I want. In Reflexil, I can see that I can change variables and calls from system.Uint to system.string. Can someone chime in and help me finish the job? Thanks for any assistance.
EDIT: work-around solution I've found is to use FFMPEG's metadata editor. It allows you to write the leading zero. More info on this wiki page.
I think this isn't possible at all even if you try to do that manually it will be set to 1 instead of 01.
I have a web page that uses a webmail service to send emails. This is on an company intranet using a Microsoft Exchange server. My website created an email with a link to an image handler on my website. In my code, I can print some debug messages and I see:
<img src='http://tav.target.com/VIBEHandler.ashx?id=z064441_45975&type=Amazing'/>
But in the email, when I view the source code, I see this:
<img src="http://tav.target.com/VIBEHandler.ashx?id=z064441_45975&type=Amazing"/>
My single quotes changed to double quotes (no big deal).
&
changed to
&
This causes the URL to not work and images appear as the red "x", indicating a missing image.
How can I preserve my URL?
Your 3rd party emailing service might be converting your HTML document to a valid XML document for compatibility reasons.
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
Basically, in XML, an ampersand character represents and XML entity, and can not be used unless you place the text within a CDATA node. Your 3rd party service seems to just be converting the & to & , which would work to safely display the value, but doesn't do too much for a URL.
http://www.w3schools.com/xml/xml_cdata.asp
If I were in your situation, I would URL encode the image URL when generating the HTML document that is being sent out. This way, it is both a proper link, and a valid XML string.
HttpUtility.UrlEncode(myUrlString);
http://msdn.microsoft.com/en-us/library/4fkewx0t%28v=vs.110%29.aspx
Hope this helps!
The best solution we could come up with is to use a single variable with multiple values separated with an underscore. This eliminates the need for the '&' symbol entirely and makes everything happy and compatible.
The URL is basically a link to an image handler so we can include images in emails without the use of attachments, shared drives, etc. The image handler can also do things like merge images together to create a single image (WAY better than trying to overlap images in emails which almost NEVER works). I simply added some code to the image handler that can check for and dissect the "meta-variable" in my URL.
http://sample.com?var=ONE_TWO_THREE
http://sample.com?var1=ONE&var2=TWO&var3=THREE
The URL now looks more clean and can have as many variables as I want so long as I put everything in the exact correct order, read it all in using the same sequence, don't miss anything, and document everything well. I COULD go one step farther and specify what each variable means:
http://sample.com?var=first-Nicolai_last-Dutka_age-34_etc-foobar
But that just tells the whole world what all my variables mean! Hypothetically, I could do:
http://sample.com?var=24154#kja&nl897q45pjkh8&&^HJ435
Then it would be up to me to determine where the breaking points are to bust that up into the variables:
24151, kja*, n1897, 45, etc
Of course, I'm not going to be that complex and will likely just stick to:
http://sample.com?var=ONE_TWO_THREE
Enjoy!
I have a Win Form application that does some boring accounting stuff and then sends it's data to some lucky recipients. I am using the Outlook 12.0 Interop objects and my applications environment ranges from office 2003 on XP to office 2007 on Win 7.
My issue lies with sending the corporate signature with the sent emails.
It contains two images and I would like to embed these images so they appear to be part of the body (assuming the receiving mail client supports that).
I have tried a few different methods of accomplishing this; but still no luck!
I have tried:
Extracting the html data from the signatures folder, changing the
html img tags src attribute to include 'file///'. This causes Outlook
to replace the 'file///' with 'CID' and I assumed it would also embed
the image... we should never assume :|. This is the method I found
worked best for getting the rest of the signature.
(After creating a new MailItem) - Grabbing the HTMLBody of the MailItem
and extracting the relevant part including the signature... This
didnt work due to the new MailItem object being very inconsistent
with it's signature. By that I mean sometimes the new item would
include the signature and sometimes it wouldn't! :s I cannot figure out why it is not always there, no other part of my code has changed!
I read on another post here about the GetInspector property... Apparently just calling this will do 'Some stuff' and the signature will magically appear in your mail item... NO!
Things I can't do:
I cannot (as much as i would like to) shove the images online
somewhere and point to them in the emails html.
I cannot use SMTP(It has to be through Outlook... sigh).
I am thinking that the best way seems to be my original method of messing about with the CID, but I do not really know much about what Outlook is doing in the background so I am having trouble figuring out what else I need to do to get the images sent along with the email.
Hoping someone out there has some idea about what I am doing wrong or what else I could try.
Please let me know if code would be helpful and I will post, (Most of the code tried is from this site... I just cannot find the links again and am trying to avoid making this question tooooo long).
Many thanks
This is not the most efficient or flexible solution you can use, but probably the most robust and portable. You can convert your image bitmap into plain HTML and embed that HTML in your e-mail signature.
The conversion is quite simple, you can use the utility I wrote (open source) here.