PDA

View Full Version : Save email as text and then send - not working?



CAMinTheToon
08-14-2008, 04:41 AM
Hi,

I have the following code that works if you run them seperatly. it saves the email as text file and then send but when i try to combine them, as below, it saves a file but only names it .txt, not by the subject name and also in the file just seems to be a path? i think possible because the msg has already been sent during the run of the code so it causes it not to work together? Also the msg comes up that a program is trying to email a msg and you have to wait 4-5 secs to allow to press yes? you could have probably(nearly) have sent the msg and saved in by the time you can press yes to sending??

Code below.



Sub SaveAsTXT()
Dim myItem As Outlook.Inspector
Dim objItem As Object
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector
If Not TypeName(myItem) = "Nothing" Then
Set objItem = myItem.CurrentItem
strname = objItem.Subject
'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 "C:\" & strname & ".txt", olTXT

Call SendOpenItem
End If
Else
MsgBox "There is no current active inspector."
End If
End Sub




Sub SendOpenItem()
'works!!!!
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Set myItem = myOlApp.ActiveInspector.CurrentItem
myItem.Send
End Sub

I am using the outlook vba help files and find them very useful but it doesnt seem to explain things like this?

thank you for any help.

Cheers,

Col