Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. Living with Outlook and improving it we hope *

Living with Outlook and improving it we hope *

Scheduled Pinned Locked Moved IT & Infrastructure
cryptographyhelphtmlsecurity
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _alank
    wrote on last edited by
    #1

    I recently posted this solution to a post concerning getting rid of Junk Mail on exiting Outlook 2003 and decided to add another fix up for a gripe I have with senders. Repost of Auto Delete Junk Mail Use Alt F11 to open the vba editor in outlook look in the projects and add code. I used the Outlook thisOutlookSession and added Private Sub Application_Quit() EmptyJunkMailFolder End Sub To it Then I added a new module and added this code *modified code to prevent deletions of unread messages and not show MsgBox more then once. Sub EmptyJunkMailFolder() Dim OutlookApp As Outlook.Application Dim olNamespace As Outlook.NameSpace Dim junkFolder As Outlook.MAPIFolder Dim OutlookMailItem As Outlook.MailItem Set OutlookApp = CreateObject("Outlook.Application") Set olNamespace = OutlookApp.GetNamespace("MAPI") Set junkFolder = olNamespace.GetDefaultFolder(olFolderJunk) Dim Status Status = 1 For Each OutlookMailItem In junkFolder.Items If OutlookMailItem.UnRead = True Then If Status = 1 Then MsgBox "A message was not marked read and will not be deleted" End If 'Set MsgBox flag so we don't get one MsgBox per each unread message Status = 0 Else junkFolder.Items.Remove (1) End If Next OutlookMailItem End Sub So now on exiting the application my Junk Folder is emptied and the items are permanently deleted. I have macro security set for prompt and I signed the code with a personal certificate I created a while back... Use Selfcert.exe to create your own digital signature this doesn't always get installed certainly not by default. Now another gripe I have is people sending me messages formatted as html so I accidentally stumbled accross this bit of code to fix that issue. Sub ConvertHTMLToPlain(MyMail As MailItem) Dim strID As String Dim olNS As Outlook.NameSpace Dim olMail As Outlook.MailItem strID = MyMail.EntryID Set olNS = Application.GetNamespace("MAPI") Set olMail = olNS.GetItemFromID(strID) olMail.BodyFormat = olFormatPlain olMail.Save Set olMail = Nothing Set olNS = Nothing End Sub You actually have to run this via the Outlook Rules builder just set the create a new rule wizard to examine all incoming email messages and use run this script feature which allows you to browse for the code available in any modules you might have created. If you already added this code it should be visible but care

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups