PDA

View Full Version : send mail using VB from outlook



ashokbioinfo
02-04-2012, 06:14 AM
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 (abc@yahoo.com)"
'.Cc = "ifneed@copy.com (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

JP2112
02-23-2012, 02:01 PM
Welcome to the board. Please use code tags when posting code.

If I understand you correctly, you do not want to save a copy of your sent messages. If so, check out the SaveSentMessageFolder Property. You can specify the Deleted Items folder as the save location.

And I know its none of my business, but I feel obligated to say that I strongly discourage this. What if you need to resend the message? Without a copy you won't have any proof you sent it or what was said.