Sending email from a web page using Outlook

I have a webpage with a button that sends an email on the page to the email recipient. We are currently using Lotus Notes and a VB script, we can create a Lotus Notes object, and one of the properties of this object is PutInFolder. After the user clicks on the email button, the script will send an email and also save the email in a specific folder on the user's computer. Now our company is switching to Outlook 2007, and instead I want to do the same with the Outlook object. Our development is just a local intranet, and there are only a few users who will have access to this. Anyway, my problem is that I cannot find the same functionality with Outlook Application.

I have an email sending that currently works using this logic. Does anyone have any ideas on how to save email in a user's Outlook folder? I tried to find a list of properties that I can name, but I cannot find anything that can be found. Perhaps I do not have the correct check in the search results.

Thank.

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

+3
source share
4 answers

For future reference ... I found the solution I was looking for. It wasn’t so bad. Here's a modified source for replicating sending and saving email to a specific folder if someone else is looking. Thanks to Tester101 for the website I was looking for. Again, this is vbscript embedded in the HTML page.




    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
    dim myInbox
    const olMailItem = 0
    'Create a new message
        set objOutlk = createobject("Outlook.Application")
        Set objNameSpace = objOutlk.Session 
        set objMail = objOutlk.createitem(olMailItem)

        Set myNameSpace = objOutlk.GetNamespace("MAPI")

    Set myExplorer = objOutlk.ActiveExplorer


    ' 6 at least on my machine pointed to the Inbox (should be the same as constant olFolderInbox).  Within the Inbox I have a folder called Test
    Set myExplorer.CurrentFolder = myNameSpace.GetDefaultFolder(6).Folders("Test")
    Set myFolder = myExplorer.CurrentFolder

    ' 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


        objMail.Save
        objMail.Move(myFolder)

        objMail.Send

    'Clean up
    set objMail = nothing
    set objOutlk = nothing

    End Sub
+2

, MailItem , SaveAs. - .

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

3 - olMSG, . OlSaveAsType.

0

I have a solution. We decided to instruct the person sending the email, and then use the Outlook rule to move the email to the specified Outlook folder. Thanks to all who responded.

0
source

Source: https://habr.com/ru/post/1752746/


All Articles