Delete email after sending

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,356
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 create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Does the mail item get saved as a garden-variety file to a garden-variety folder?
 
Last edited:
Upvote 0
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.
 
Upvote 0
I don't know anything about CDO. In Outlook, you would set DeleteAfterSubmit true for the MailItem.
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,827
Members
449,190
Latest member
rscraig11

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
Back
Top