none
send mail using macro RRS feed

  • Question

  • Hi all,

    Iam trying to send mail through outlook but not getting the output. Here is the code below.

    when I am able to send the mail and check "send items" folder, it should not be there (mail should be auto deleted i.e. send item folder should be blank)

    Sub mail()

    Dim objOutlook As Object
    Dim objOutlookMsg As Object
    Set objOutlook = CreateObject("Outlook.Application")
    Set objOutlookMsg = objOutlook.CreateItem(0)
    With objOutlookMsg
       .To = "abc@yahoo.com"
       '.Cc = "ifneed@copy.com"
       .Subject = "Hello World (one more time)..."
       .Body = "This is the body of message"
       .HTMLBody = "HTML version of message"
       '.Attachments.Add ("c:\myFileToSend.txt")
       '.Send 'Let´s go!
    End With
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing

    End Sub

     


    ashok
    Saturday, February 4, 2012 1:09 PM

Answers

  • DeleteAfterSubmit parameter

    http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._mailitem.deleteaftersubmit.aspx#Y0

     


    Oskar Shon, Office System MVP

    Press if Helpful; Answer when a problem solved

    • Marked as answer by ashokbioinfo Sunday, February 5, 2012 2:51 PM
    Saturday, February 4, 2012 3:17 PM