SPF compliant CDO message

I wrote this a while back as I couldn’t find a nice example anywhere for sending SPF compliant CDO.message emails. It also copes with setting message importance which is another awkward thing. Let me know if you have any problems or have any suggestions to improve it.

Sub sendemail(strFrom, strTo, strSender, strBcc, _
   strSubject, strBody, intType, intImportance)
Dim objMessage ' As CDO.Message
objMessage = Server.CreateObject("CDO.Message")
With objMessage
   .Fields("urn:schemas:httpmail:importance").Value = intImportance
   .Fields("urn:schemas:httpmail:priority").Value = intImportance - 1
   Select Case intImportance
      Case 0
         .Fields("urn:schemas:mailheader:X-Priority").Value = 5
      Case 1
         .Fields("urn:schemas:mailheader:X-Priority").Value = 3
      Case 2
         .Fields("urn:schemas:mailheader:X-Priority").Value = 1
      Case Else
         .Fields("urn:schemas:mailheader:X-Priority").Value = 0
   End Select
   .Fields("urn:schemas:mailheader:X-MSMail-Priority").Value = intImportance
   If Not isNull(strSender) and strSender  strFrom then
      .Fields("urn:schemas:mailheader:return-path").Value = strSender
      .Fields("urn:schemas:mailheader:reply-to").Value = strFrom
   End If
   .Fields.Update()
   .To = strTo
   If Not isNull(strSender) and strSender  strFrom then
      .Sender = strSender
   End If
   If Not isNull(strBcc) Then
      .BCC = strBcc
   End If
   .From = strFrom
   .Subject = strSubject
   If CInt(intType) = 1 Then
      .TextBody = strBody
   Else
      .HTMLBody = strBody
   End If
   .Send()
End With
objMessage = Nothing
End Sub

This is generally useful for web generated emails (like send a friend forms etc.), simply specify the users address as strFrom and a generic local address (noreply@mydomain.com) as strSender.

More generally, here are some good CDO examples.

Not feeling great

Yesterday late afternoon I started to feel extreme hunger pains which seemed very odd as I had well throughout the day. Pains continued after I’d eaten my evening meal (admittedly it was a kebab so I did kinda asked for it) so I went to bed really early. I didn’t sleep very well as the pains persisted but felt a bit better this morning when I got up. I’m still not feeling 100% now but feel better than I did this time last night.

The kitchen is coming along really nicely now and all the building work and majority of the plastering is now complete. The new units are going in tomorrow so it may resemble a kitchen again soon!

I finally ordered the chip for the coupé yesterday which has now been dispatched. I really do hope it arrives in time to have it fitted on Friday.