Excel VBA Change default sent items folder

mohammedus

New Member
Joined
Sep 9, 2011
Messages
1
I have a Macro in Excel which creates and send's an email using a group mailbox as the sent from email.

For emails sent using this macro I would like to save the sent items in the group mailbox rather than my default one. I have created the following line but cannot get it to work:

Set Item.SaveSentMessageFolder = OutApp.Session.Folders("Mailbox - Group Mailbox").Folders("Sent Items")


Complete Macro:

Sub run()

Dim OutApp As Object
Dim OutMail As Object
Dim sh As Worksheet
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set sh = Sheets("sheet1")
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With OutMail
.SentOnBehalfOfName = "Group Mailbox"
.to = "test@email.com"
.ReplyRecipients.Add "Group Mailbox"
.Subject = " Invoice IN00000XXXX"


Set Item.SaveSentMessageFolder = OutApp.Session.Folders("Mailbox - Group Mailbox").Folders("Sent Items")


MyDate = WorksheetFunction.Text(Now, "hh:mm:ss")
If MyDate >= "12:00:00" Then
Greeting = "Good Afternoon"
Else
Greeting = "Good Morning"
End If
.body = Greeting
.body = .body & "<BR><BR>"
.body = .body & "Please find attached Invoice IN00000XXXX. " & "If you have any queries, please do not hesitate to contact us by replying to this email."
.body = .body & "<BR><BR>" & "To access the attached document you will require Adobe® Acrobat® reader, which is free to download from www.adobe.co.uk/reader/"
.body = .body & "<BR><BR><BR>" & "Kind Regards" & "<BR><BR><BR>"
.body = .body & "<i>The Finance Team</i>"
.htmlbody = .body

If Worksheets("Sheet1").Range("A1") = "" Then
Else
.Attachments.Add Range("A1").Value
End If

If Worksheets("Sheet1").Range("A2") = "" Then
Else
.Attachments.Add Range("A2").Value
End If

If Worksheets("Sheet1").Range("A3") = "" Then
Else
.Attachments.Add Range("A3").Value
End If

.display
End With
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With

End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,224,616
Messages
6,179,911
Members
452,949
Latest member
beartooth91

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