Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDO emailing - can I set Priority or Importance?

Status
Not open for further replies.

dbMark

Programmer
Apr 10, 2003
1,515
0
0
US
I am switching for AspSmartMail to CDO messaging which seems to be a subset of Exchange's resources. The main reason is that all our computers can access CDO without adding a DLL but also because AspSmart seems to no longer exist.

I am looking for a way to send Importance or Priority settings with CDO but can't seem to find a way to do it. On the internet others too have expressed frustration with this.

Does CDO have a reliable way to set Importance levels (0,1,2) or Priority levels (-1,0,1)? Mike Gagnon wrote a good FAQ how to use CDO in faq1251-4969 but these options aren't mentioned, neither did Microsoft here...

 
Here is how to do it.

Code:
With iMsg
        .Configuration = iConf
        .To = "me@hotmail.com"
        .CC = ""
        .BCC = ""
        .From = "me@somewhere.com"
        .Subject = "This is a test"
        .TextBody = "This is the body text"  && Plain text
        .Fields("Priority").Value = 1   && -1=Low, 0=Normal, 1=High
        .Fields.Update()
        .Send()
Endwith


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
I thought I tried that. I don't have my code handy, but I suspect I didn't add the line for the fields update.

I discovered that I couldn't pull attachments out for the next email, so I followed the example as shown but when I loop through multiple emails, I create and destroy CDO.Message for each email. I just set CDO.Configuration once and keep it until the end.
 
BTW CDO does not need destruction according to Microsoft or nulling for that matter, it destroys itself.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
I checked my code, I was already doing what you suggested. I tried every variation I could think of but nothing worked for .Fields("Priority").Value. I am testing with Outlook on XP and I believe my remote email server is Exchange, so perhaps this is why the simple Priority field doesn't work for me. My suggestion to all is that if one method won't work for you, then try another field or schema and you'll probably find one that does work for your specific server/application combination.

This page was especially helpful, though I could not get the following two methods from the early days of Internet emailing to display any flags for Outlook. I was able to set and send them in the header, but Outlook did not display any indicators (1/2=Urgent, 4/5=Low):

Code:
.Fields("urn:schemas:mailheader:X-Priority").Value
.Fields("urn:schemas:mailheader:X-MS-Priority").Value
This is a solution that works for me with Exchange and Outlook:

Code:
* In my code I'm using "H" or "L" to denote High/Low settings
.Fields("urn:schemas:httpmail:importance").Value = ICASE(myPriority="H",2,myPriority="L",0,1)
.Fields("urn:schemas:httpmail:priority").Value = ICASE(myPriority="H",1,myPriority="L",-1,0)
Some links to Microsoft documentation:

urn:content-classes:message

Importance Field (urn:schemas:httpmail:) Values: Low 0, Normal 1, High 2.

Priority Field (urn:schemas:httpmail:) Values: Urgent 1; Normal 0; Non-Urgent -1.

I always detroy CDO.Message object. I found that the attachments persisted. It is a collection that I don't know how to empty or clear. So I decided to close it after sending each email message whether I had attachments or not.
 
Upon further testing, Outlook looks at ONLY the Importance flags. Here is what worked with Exchange/Outlook:

Code:
* Flags can be sent either as numbers (httpmail) or words (mailheader)
* flags: 0=Low 1=Normal 2=High
.Fields("urn:schemas:httpmail:importance").Value = ICASE(myPriority="H",2,myPriority="L",0,1)
.Fields("urn:schemas:mailheader:importance").Value = ICASE(myPriority="H","High",myPriority="L","Low","Normal")
Other settings can also be inserted into the email, but are ignored when viewed in Outlook:

Code:
* in header but ignored, not sure data is right
.Fields("urn:schemas:httpmail:priority").Value = {-1=Non-urgent 0=Normal 1=Urgent}
.Fields("urn:schemas:mailheader:X-MSMail-Priority").Value = {"High",etc.}
.Fields("urn:schemas:mailheader:priority").Value = {-1=Non-urgent 0=Normal 1=Urgent}
Some of these ideas came from:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top