Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send email and Save sent email as msg file

Status
Not open for further replies.

neemi

Programmer
May 14, 2002
519
GB
Though vba I compose an email and send it and also save it as a msg file. Code as below:

Code:
With MailOutLook                        
            .To = strTo
            .cc = strCC
            .subject = strSubject
            .Body = strBody
            .SaveAs strPath,OLMsg
            .Send
End With

However This saves the a copy of the unsent message. What I would like to do is send the message and save a copy of the actual sent message so that it does not say message not sent on the saved msg file.

Has anyone done anything similar or come accross any thing that will help.

Hope I've explained correctly.

Cheers,
Neemi
 
take a look at faq707-5368

This shows you how to access a outlook folder, all you need to do is change it to the sent items folder, do a str match on the fields you have above , then save the email.

Chance,

Filmmaker, taken gentleman and crunch day + 22
 
Perhaps this ?
With MailOutLook
.To = strTo
.cc = strCC
.subject = strSubject
.Body = strBody
.Send
DoEvents
.SaveAs strPath,OLMsg
End With

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
How do I refer to the Sent folder to do a search?

PHV, that would not work like that.
 
Set itm = ns.GetDefaultFolder(olFolderSentMail)
in relation to the code in the FAQ

Chance,

Filmmaker, taken gentleman and He tan e epi tas
 
Would this help?

A,

Code:
Sub ReadFolderContents()

    Dim objApp As Object
    Dim objNS As Object
    Dim folder As Object
    Dim currItem As Object
    Dim i As Integer
    
    Set objApp = CreateObject("Outlook.Application")
    Set objNS = objApp.GetNamespace("MAPI")
        
    Set folder = objNS.Folders("Your Mailbox name").Folders("Sent Items")

    For i = folder.Items.Count To 1 Step -1

        Set currItem = folder.Items(i)
    
        'Then Do what you want to do with each email in the folder

    Next i

    Set currItem = Nothing
    Set folder = Nothing
    Set objApp = Nothing
    Set objNS = Nothing
  
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top