views:

107

answers:

4

I have a webpage that has a button that sends a letter on the page to an email recipent. Currently we are use Lotus Notes and with VB script, we are able to create an object of Lotus Notes and one of the properties for this object is PutInFolder. After the user clicks on the email button, the script will send the email and also put save the email in a certain folder on the user's computer. Our company is now switching over to Outlook 2007 and I'm looking to do the same thing with an Outlook object instead. Our development is local intranet only, and there are only a few users that will have access to this. Anyway, my problem is I cannot seem to find the same functionality with an Outlook Application.

I do have the send of the email currently working using this logic. Does anyone have any ideas on how to save the email in the user's outlook folder? I tried looking for a list of properties that I can call but I cannot find anything searching. Maybe I don't have the right terminalogy in the searches.

Thank you.

sub send_mailvb(sendto, sendcc, sendbcc, subject_text, body_text, attachment1, attachment2, attachment3)

'Open mail, adress, attach report
dim objOutlk    'Outlook
dim objMail 'Email item
dim strMsg
const olMailItem = 0
'Create a new message
    set objOutlk = createobject("Outlook.Application")
    set objMail = objOutlk.createitem(olMailItem)

' Setup send to
    objMail.To = sendto

' Setup send cc
If sendcc <> "" Then
objMail.cc = sendcc
End If

' Setup send bcc
If sendbcc <> "" Then
objMail.bcc = sendbcc
End If

'Set up Subject Line
    objMail.subject = subject_text

'Add the body

    strMsg = body_text & vbcrlf

'Add an attachments
If attachment1 <> "" Then
    objMail.attachments.add(attachment1)
End If

If attachment2 <> "" Then
    objMail.attachments.add(attachment2)
End If

If attachment3 <> "" Then
    objMail.attachments.add(attachment3)
End If

    objMail.body = strMsg
    objMail.display 'Use this to display before sending, otherwise call objMail.Send to send without reviewing

'Clean up
set objMail = nothing
set objOutlk = nothing

End Sub

A: 

I found this article. It might be something tha could help.

http://www.outlookcode.com/codedetail_print.aspx?id=1041

If not this site has great resources for working with outlook.

spinon
-1: Outlook **doesn't work** from ASP.NET or any other server application.
John Saunders
Where does he mention anything about server application or asp.net? What's up with the negative about something that doesn't even apply to this question.He says local intranet using vb.
spinon
@spinon: good catch. I've removed the downvote and will delete my answer.
John Saunders
Thanks John. I didn't think i was that off.
spinon
Thank you guys. I tried the example above but it didn't like the Dim NS as NameSpace in the imbedded html vbscript. I don't remember the exact error. I suppose I should have shown how my script tag looked. <SCRIPT LANGUAGE="VBScript">' code here.</SCRIPT>
Michael
An alternative that I thought of, is to send a copy of email to the user by putting the user in the BCC, then creating a rule in the user's outlook to move the email after they receive in their inbox.
Michael
A: 

It looks like the MailItem object has a Save method, as well as a SaveAs method. So you should be able to do something like this.

objMail.SaveAs "C:\Test.msg", 3 

The 3 is to save the message in olMSG format see OlSaveAsType Enumeration.

Tester101
Thank you for the reply. I'm not certain if they want save to the pc. However maybe to the network. But it has to be by user. We'll see.
Michael
A: 

I have a solution. We've decided to bcc the person sending the email and then use an outlook rule to move the email to the specified outlook folder. Thanks to everyone that replied.

Michael
A: 
Michael