A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

MailItem.SaveAs not working



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old May 10th 10, 12:13 PM posted to microsoft.public.outlook.program_vba
Chris
external usenet poster
 
Posts: 280
Default MailItem.SaveAs not working

I am trying to save messages as a MSG format. I checked on the forum and
found the code but when I save, the file name is not completely written and
the file size is 0 bytes. Right now the code is only for the open message.
Ideally, I would like the code to be run on an Outlook folder. I am
operating in a Vista Enterprise environment. Any help would be greatly
appreciated.

-----VBA Code-----
Sub SaveAsTXT()
Dim myItem As Outlook.Inspector
Dim objItem As Object
Dim strname As String


Set myItem = Application.ActiveInspector
If Not TypeName(myItem) = "Nothing" Then
Set objItem = myItem.CurrentItem

strname = "U:\E-Mail\" & objItem.SenderName & " " & objItem.Subject
& objItem.Sent & ".msg"
MsgBox strname
'Prompt the user for confirmation
Dim strPrompt As String
strPrompt = "Are you sure you want to save the item? " & _
"If a file with the same name already exists, " & _
"it will be overwritten with this copy of the file."
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
objItem.SaveAs strname, olMSGUnicode
End If
Else
MsgBox "There is no current active inspector."
End If
End Sub
-----End of VBA Code-----
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MailItem SaveAs Koen Verwimp Add-ins for Outlook 2 September 22nd 08 01:41 PM
MailItem.SaveAs encoding characters wrong from HTML message MattS Outlook and VBA 3 April 1st 08 02:26 PM
MailItem.SaveAs method Mrunali Outlook - Using Forms 0 April 17th 07 03:16 PM
_MailItem - SaveAs MON205 Add-ins for Outlook 1 February 22nd 07 06:01 PM
How can I create a MailItem that displays like a received MailItem ? Clive Outlook - Using Forms 0 February 27th 06 04:14 PM


All times are GMT +1. The time now is 06:58 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.