jwinney
asked on
Setting Expiry of a CDO Message (SMTP)?
I'm sending emails within my company to users, using CDO, Roughly like below.
I'd like the emails to self expire. Is this possible?
I know that you can do this by sending the emails through Outlook, but that isn't possible in my situation. I need to use the method below.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
Private Sub Form_Load()
Dim test As New CDO.Message
test.To = "him@mycompany.com"
test.From = "me@mycompany.com"
test.Subject = "Test Message"
test.AddRelatedBodyPart "U:\Inetpub\wwwroot\~resou rces\tech- newsletter -head.jpg" , "tech-newsletter-head.jpg" , cdoRefTypeId
test.AddRelatedBodyPart "U:\Inetpub\wwwroot\~resou rces\regio ns.jpg", "regions.jpg", cdoRefTypeId
test.Configuration.Fields. Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of remote SMTP server
test.Configuration.Fields. Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "my.mail.server"
'Server port
test.Configuration.Fields. Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
test.Configuration.Fields. Update
'Read HTML file for message body
Open "u:\inetpub\wwwroot\temp3. htm" For Input As #1
While Not EOF(1)
Line Input #1, strHTMLT
strHTML = strHTML & strHTMLT
Wend
Close #1
test.HTMLBody = strHTML
test.Send
Set test = Nothing
End Sub
I'd like the emails to self expire. Is this possible?
I know that you can do this by sending the emails through Outlook, but that isn't possible in my situation. I need to use the method below.
--------------------------
Private Sub Form_Load()
Dim test As New CDO.Message
test.To = "him@mycompany.com"
test.From = "me@mycompany.com"
test.Subject = "Test Message"
test.AddRelatedBodyPart "U:\Inetpub\wwwroot\~resou
test.AddRelatedBodyPart "U:\Inetpub\wwwroot\~resou
test.Configuration.Fields.
'Name or IP of remote SMTP server
test.Configuration.Fields.
'Server port
test.Configuration.Fields.
test.Configuration.Fields.
'Read HTML file for message body
Open "u:\inetpub\wwwroot\temp3.
While Not EOF(1)
Line Input #1, strHTMLT
strHTML = strHTML & strHTMLT
Wend
Close #1
test.HTMLBody = strHTML
test.Send
Set test = Nothing
End Sub
ASKER
Hi,
I've tried that. This article refers to using Outlook itself by creating a MAPI session, not SMTP
Cheers
John
I've tried that. This article refers to using Outlook itself by creating a MAPI session, not SMTP
Cheers
John
Expiry is a standard header, so just add it to the Message object:
test.To = "him@mycompany.com"
test.From = "me@mycompany.com"
test.Subject = "Test Message"
test.Fields.Item("urn:sche mas:mailhe ader:expir y") = "Sat, 26 Apr 2006 00:00:00 -0800"
A list of headers can be found at:
http://msdn.microsoft.com/library/en-us/cdosys/html/dbca4fb9-afcb-4716-9e0c-4bff45ca0b60.asp
Cheers,
-Bill
test.To = "him@mycompany.com"
test.From = "me@mycompany.com"
test.Subject = "Test Message"
test.Fields.Item("urn:sche
A list of headers can be found at:
http://msdn.microsoft.com/library/en-us/cdosys/html/dbca4fb9-afcb-4716-9e0c-4bff45ca0b60.asp
Cheers,
-Bill
ASKER
Hi wnross,
Thanks, I tried that after I'd posted this question. It didn't appear to work for me. Have you tred it? It seems to be the correct way of doing it. Wondering if my SMTP server is doing something....
Cheers
John
Thanks, I tried that after I'd posted this question. It didn't appear to work for me. Have you tred it? It seems to be the correct way of doing it. Wondering if my SMTP server is doing something....
Cheers
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you put expiry into the configuration object or forgot to use Update, your attempt would have been discarded
ASKER
Excellent !!
This worked:
test.Fields.Item("urn:sche mas:mailhe ader:Expir y-Date") = "Wed, 26 Apr 2006 15:40:00 +0100"
test.Fields.Update
Thanks
John
This worked:
test.Fields.Item("urn:sche
test.Fields.Update
Thanks
John
No problem, glad to help
-Bill
-Bill
you could look at this article
source: http://support.microsoft.com/?kbid=195381
----------
'This message will expire at 6:00 PM on October 23, 1998
test.Configuration.Fields.
----------
hope this helps a bit
bruintje