Delete email after sending

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,348
Code:
  Sub sendmail()
'
    With CreateObject("CDO.message")
   
        With .Configuration.Fields
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp-mail.outlook.com"
            .Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 1
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Fred@hotmail.co.uk"
            .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "FredPassword"
            .Update
        End With
        .To = "SomeoneElse@anotherdomain.co.uk"
        .From = "Fred@hotmail.co.uk"
        .Subject = "Test email"
        .TextBody = "Some text to go into the body of the email"
        .Send
    End With
End Sub

This code sends an email OK but I would like to know how (if it's possible) to automatically delete the email after sending.
Can anyone help.
I'm using Excel 2002 at the moment!
Thanks
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,836
Office Version
  1. 2010
Platform
  1. Windows
Does the mail item get saved as a garden-variety file to a garden-variety folder?
 
Last edited:

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,348
Does the mail item get saved as a garden-variety file to a garden-variety folder?

Not sure what you mean by this.. It's a regular internet email and by default a copy is saved to the 'Sent items' folder.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,836
Office Version
  1. 2010
Platform
  1. Windows
I don't know anything about CDO. In Outlook, you would set DeleteAfterSubmit true for the MailItem.
 

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,348
Yes, I can do it in Outlook using DeleteAfterSubmit = True, but this is the first time I need to do it using internet mail - hence the question.
Thanks for your input anyway.
Regards
 
Last edited:

Forum statistics

Threads
1,181,060
Messages
5,927,893
Members
436,575
Latest member
Tiger750

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top