Category Archives: Uncategorized
Embedded Images in HTML Emails with .Net
I had looked for a few examples of how to send embedded images in an html email with the .net api, and the first few I found didn’t work.
This code, found on the blog of one Mike Pope, did work however:
Imports System.Net.Mail
Imports System.Net.Mime
Imports System.IO
Dim fromAddress As String = "mike@elsewhere.com"
Dim toAddress As String = "mike@elsewhere.com"
Dim subject As String = "Test EmbeddedImage"
Dim contentId As String = "image1"
Dim path As String = Server.MapPath("~") & ""
Dim filename As String = path & "MyPicture.jpg"
Dim body As String = "Here is a linked resource: <img src=""cid:image1""/>"
Dim mailMessage As New MailMessage(fromAddress, toAddress)
mailMessage.Subject = "Testing embedded image"
Dim av1 As AlternateView
av1 = AlternateView.CreateAlternateViewFromString(body, Nothing, _
MediaTypeNames.Text.Html)
Dim linkedResource As LinkedResource = New LinkedResource(filename)
linkedResource.ContentId = contentId
linkedResource.ContentType.Name = filename
av1.LinkedResources.Add(linkedResource)
mailMessage.AlternateViews.Add(av1)
mailMessage.IsBodyHtml = True
Dim mailSender As New SmtpClient("smtpHost")
Try
mailSender.Send(mailMessage)
labelStatus.Text = "Message sent!"
Catch ex As Exception
labelStatus.Text = ex.Message
End Try
Car Negotiator
My wifes 12 year old Corolla was still running strong, but it was in need of some work and seeing as how we just had our first kid we decided it was probably time to get a new car.
I absolutely hate car shopping. I hate the fact that you end up wasting so much time at the dealer, the BS pricing tricks, the high pressure sales tactics, the “treating me like I’m an idiot who doesn’t that monthly price is ues, the “let me go talk to my manager” crap, I hate all of it.
So, I decided to try hiring a car negotiator.
http://www.nomorehaggling.com/
I had heard Phil Landers on WGN Radio a few years ago, and thought it sounded like a great idea. I wasn’t in the market for a car at the time, but a few years later when I googled “car negotiator” he was the first in google.
For a fee of $395, Phil made 2 trips out to the dealer with us (one to negotiate the car, and one to pick it up). He probably spent about 5 hours in total.
I didn’t find any reviews of him online, so I figured I would write this one so anyone in the future searching can feel better about going this route, as I would recommend him to others.
Most people want to know right off the bat, did he earn the money. Well from a strictly $$ sense on the price of the car, we probably broke even. On my first trip to the dealer (w/o Phil, when I was just looking) the salesman started right off talking about dealer invoice. Normally it has been my experience that dealers will start with the sticker price, and then offer you some small amount below that as the first offer. You then have a major gap between the dealers first offer, and where you think the final price should end up.
With, Phil we ended up about 500 lower than the dealer offer, or about 500 bucks worth of dealer profit based on their invoice, but several hundred below invoice when you include a cash back deal that was going on. So strictly on price, I don’t think it is beyond reason that I would have been able to get them to come down 500 from their offer, even if there wasn’t much room for haggling left.
However, if the dealer hadn’t been forthcoming on the first offer, I’m guessing I’d have probably ended up paying more than that.
The place where Phil really helped (in our deal) was with the other stuff. The car we had driven 2 days before was already sold, and there was a similar car on the lot, with a slightly less appealing color, and with an extra “protection package” option installed that would have cost us probably 400 more. I think my wife and I were ready to conceed and just take this car, as the color wasn’t bad, and the cargo tray aspect of the protection package would be nice, even if we were paying too much for that option. However, before we made this move Phil got the salesman to search the inventory of other local dealers for the color and options we wanted. I didn’t realized that dealers will swap cars like that w/ no extra charge to the customer.
Sure enough, a dealer in Schaumburg had the exact color/trim/options we wanted. So we got exactly the car we wanted, and didn’t end up paying extra for some stuff we didn’t want just because it was on site at the dealer.
They lowballed us on the trade in: 500 bucks. Phil went to work arguing for us. The guy came back after “taking another look” they increased their offer by 200%. Phil told us he thought 1600 was the lowest we should accept, and so their offer of 1500 was pretty close. Phil made the guy go back to his manager again and he returned with “Split the difference: 1550 and free car washes for life.” No deal. It’s 1600 or we take it to carmax (where we already had an offer). They relented and accepted 1600 for the trade.
When we went back to pickup the car the next day, there had been a mixup and the wrong car was brought in from the other dealer. It didn’t mean we were getting the wrong car, just that we wouldn’t be driving it home that night. My wife half jokingly said that they should throw in the cargo tray for free for the mixup. Phil thought that was a good idea and argued for them to do just that: and they did.
When they told us we could come back the next day to pickup the right car, Phil convinced them to have someone deliver the car to our house, which was nice. In addition to all this, he got them to give us any dealer installed options at cost, so we ended up getting all season floor mats at 1/2 the asking price.
As we went over all the paperwork, Phil made sure all the paperwork and numbers were legit and make sure we didn’t sign any of the stuff regarding the appearance of the car (which wasn’t there), which they were still trying to get us to sign (duh!).
During the entire process we never had to do any of the talking. Phil drove the process with the salesmen and we cut through all the crap that you typically expect when buying a new car.
So if you hate the car buying process, and you want to make sure you leave the dealership without getting ripped off, and would rather not deal with any of the headache and stress involved in the car buying process, I’d highly recommend working with a car negotiator and I’d highly recommend Phil.
Sending Faxes Online
Since we recently dropped AT&T in favor of a $6/month plan from Callcentric.com, I haven’t been able to use my fax machine.
It’s not really suprising, even though it’s SUPPOSED to work, it’s sone of those things where, the fax machine is trying to do digital to analog, and then the VOIP provider is doing analog to digital and this second conversion has an accepted amount of packet loss as part of the equation.
If that amount is above the tolerance level of the 2 communicating fax machines, then it doesn’t work.
So when I needed to send a fax the other day I again when looking for a simple online solution for a 1 time user like myself and I think I found it: http://faxzero.com/.
There are tons of place out there that offer fax services online (http://fax.1888usa.com/), and many that offer some kind of free version, but they usually fall into 2 categories: 1) you can send a free fax, but it’s limited to 1-3 pages (I needed to send 4 pages) or 2) you can pay a monthly subscription to get the “pro” version.
FaxZero has the free version (lmiit 3 pages) but they also have a $2 option that you can use to send up to 15 pages (and no ad cover letter).
Perfect! I uploaded my PDF, paid 2 bucks, got a confirmation message in my inbox. Just what I wanted.
CSLA and the watch window
One of my biggest complaints about using CSLA has been the issue of Visual Studio’s failure to work correctly in the watch window with CSLA objects.
I wrote a post a while back about my issues:
So for example I have a simple list called “projects” which is of type ProjectList containing ProjectListItems.
If I put “projects” in the watch window, for Value I get:
“Count = {System.TypeLoadException}”
If I put “projects(0)” in the watch window, I get:
{“The generic type ‘System.Collections.ObjectModel.Collection`1’ was used with the wrong number of generic arguments in assembly ‘mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.” : “System.Collections.ObjectModel.Collection`1”}
Rocky’s response was:
This is a known issue. I’ve actually talked to the VS debugger team about this, and they didn’t have a satisfactory answer – and certainly not a solution. This issue has existed since 2005 when generics were introduced into .NET.
Well, after doing some digging I think I have come across a few work arounds.
If I were to use the Watch Window and put:
projects.Count
it would throw an error. But if I put:
projects.Count.ToString
then I get the correct result.
Also when picking a specific item:
projects.Item(2)
I get the same exception. However, if I use:
CType(projects.Item(2),Object)
I get the object as expected!
I hope this helps out others as this is really important when debugging an application.
Javascript scope in for loops
In JavaScript, you don’t need to define your variables. You can just up and use any variable as you see fit, like this:
asdfasdf = 'asdfasdf';
However, these variables will then be created in a global scope, which is bad.
I came across a bug today that involved for loops and globally undefined variables. It’s not as clear what is happening when the counter variable is first used inside the for declaration, but the result is the same: a global variable:
function test2() {
for (i = 0; i < 10; i++) {
alert(i);
test3();
alert('now i is ' + i);
}
alert('done');
}
function test3() {
for (i = 0; i < 10; i++) {
// do whatever here
}
}
In this example, test2()’s for loop will only run 1 time, because test3’s loop ends up using the same variable.
To fix this problem you need to define your looping variables:
for (var i=0; i < 10; i++)
This is a best practice that you should remember to do.
Comcast turns off your internet
Last night, all of a sudden, my internet connection went down.
After a while, all my web requests started getting directed to a comcast page that said:
“You will need to activate your account”
telling me that I needed to download some software. Total BS.
The link for the software didn’t even work. I tried rebooting the modem, the router, nothing worked.
So after an hour in a comcast support chat (using my EVDO card for internet) they finally added my modem back to their system (or whatever).
If you get this message, and you are not a new customer, either comcast f’ed up (which is likely because they are possibly the worst company on earth) or you didn’t pay your bill.
Skype on Mac OSX
My wife just tried to install Skype on her Mac OSX computer. Of course it didn’t work. Nothing ever works on Macs it seems.
After lots of messing around I found some random suggestion on some forum to try this:
1. Quit Skype
2. Go to the folder “ ~/Library/Application Support/Skype/ “
3. Delete the file “shared.xml”
4. Start Skype
Amazingly, this worked.
Disabling SSRS Subscriptions
As far as I could find, there is no easy way to disable (not delete) an SQL Server Reporting Subscription.
We thought we had found a way to do this by changing the schedule to “run once” and set an “End Date” so that it would never run after that date.
This seemed to work, but after a restart of the server this weekend, the job executed on monday morning.
I’m not sure why it happened Monday morning ( as opposed to Sunday morning, as the machine was restarted on Saturday night) or if has anything to do with today being the first of the month, but either way, this didn’t work and people were emailed some useless notice that they didn’t need.
So, if you are using this method to disable your SSRS reports, watch out.
Doing P2V with HyperV
I had recently tried to use my Windows Home Server to restore a laptop image to a VM running inside HyperV.
In the event that my machine totally died (not just a hard drive issue) I could restore the image to a VM and work from there while I got back on my feet with a new laptop.
Unfortunately I didn’t find any way to make this work. I ended up doing all this work and in the end, I couldn’t boot.
A disk read error occurred
Press ctrl+alt+delete to restart.
I tried everything I could think of, repairing the MBR, running fixboot, doing a windows repair, restoring the hal dll from i386 etc. Nothing worked.
So I gave up on using WHS to create an instance of my dev machine, and fell back on just trying to do a P2V of any type.
I came across Disk2VHD, a free Systernals tool. This tool includes the options to run on the source machine while online, and also provides an option to “Fix” the HAL (hardware abstraction layer). I think this was part of my original problem (the HAL issue). My computer was setup to use SATA drivers, and HyperV only supports virtual IDE drivers. I think (but am not sure) that this is what was causing my problem w/ using the WHS restore.
So anyway, Disk2VHD runs super fast, and pretty soon I had a VHD to try out.
Now, this VHD didn’t work either, but it would get me further along. I would see the windows splash screen before the black screen of death.
What followed was a weird set of steps trying to figure out why things wouldn’t work, but in the end, I never ended up needing to disable anything…. so I’m just going to try to write down the steps I took as best I can.
- After the first BSOD I booted to safe mode (using F8).
- Safe mode worked, and it seemed to find some new hardware, as I would have expected, but I don’t think it found any of the drivers it needed (so maybe I had ejected the virtual windows CD or something).
- Booting normally gave the black screen of death again.
- I then found this page with instructions on how to replace the HAL. Really these instructions were how to do Disk2VHD to a working VM, but I had already done most of the steps except the hal replacement. I’m going to replace those instructions below:
- 1)Downloaded Disk2VHD (v 1.3) from sysinternals (free) and unzipped on the laptop
2)Find a place to store the new vhd – I used a 320GB external USB, but any storage device that pc can see and is big enough to hold your hard disk should work
3)Run Disk2VHD and input the name and location for the new file
4)On your virtual host create a new VPC (I use Virtual PC 2007) and add that new vhd you just created as the primary hard disk.
5)Make sure you have an ISO of WinXP or an actual disk. If using an iso you’ll need to mount it so it can be booted from.
6)Fire up the new vpc and have it boot from that XP disc.
7)Let it run setup and then select option 2 (R) to get repair console
Login in to windows (need admin pw)
9)Type “cd system32” press enter
10)Assuming your CD (or mounted iso) is drive D – Type “expand d:i386halacpi.dl_” press enter
11)Type “copy halacpi.dll hal.dll” press enter and then press y
12)Reboot
13)Press F8 to get to safe mode
14)After the message that new stuff was installed, click OK for reboot
15)After system boots back up, log in and install VM Additions - IIRC I still got the black screen of death. It’s possible that at this point behind the scenes it was doing a check of my disck or something, but I can’t tell in the VM if the HDD is going or not so I just assumed it was locked.
- I booted to safe mode and used MSconfig to disable everything, and also used /SOS, and some other options.
- What followed was just a series of successful boots with me enabling more and more until I had everything enabled and it all still worked, so I’m not sure why I was getting the BlackSOD before I started this set of SafeMode boots.
- Another thing I did at some point (maybe more than once) was try to install the VM Integration Services, which says that it’s updating the HAL, so maybe that had something to do with it too.
The next 2 things that I’m going to try are, running a WHS restore to a VM that is already working (I don’t think this will matter, but we’ll see), and 2 trying to use the Disk2VHD on a machine that has a VHD mounted as a secondary drive. I don’t konw if this is even possible, but I was thinking that I could use WHS to create the VHD, mount the VHD as X: on some machine, and then tell Disk2VHD to create a VHD from X: and instruct it to to the “Fix HAL” thing. I’m guessing that will not work as well, but we’ll see.