代码之家  ›  专栏  ›  技术社区  ›  Michael

使用Outlook从网页发送电子邮件

  •  3
  • Michael  · 技术社区  · 16 年前

    我有一个网页,有一个按钮,发送一封信的网页上的电子邮件收件人。目前我们使用的是Lotus Notes,使用VB脚本,我们可以创建一个Lotus Notes对象,这个对象的一个属性是putinfolder。在用户单击电子邮件按钮后,脚本将发送电子邮件,并将电子邮件保存到用户计算机上的某个文件夹中。我们公司现在正切换到Outlook2007,我希望用一个Outlook对象来代替它。我们的开发仅限于本地Intranet,只有少数用户可以访问它。无论如何,我的问题是,我似乎找不到与Outlook应用程序相同的功能。

    我确实使用这个逻辑发送了当前正在工作的电子邮件。有人对如何将电子邮件保存到用户的Outlook文件夹有什么想法吗?我试图查找可以调用的属性列表,但找不到任何搜索内容。也许我在搜索中没有正确的术语。

    谢谢您。

    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
    

    4 回复  |  直到 16 年前
        1
  •  2
  •   Michael    16 年前

    供将来参考…我找到了我想要的解决方案。一点也不糟糕。这里是修改后的源文件,用于复制发送和保存电子邮件到特定的文件夹,以防其他人看到。感谢Tester101为我寻找的网站。这也是嵌入在HTML页面中的vbscript。

    
    
    
        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
  •  0
  •   John Saunders    16 年前

    我找到了这篇文章。这可能是她能帮助的。

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

    如果不是,此网站有大量资源可用于使用Outlook。

        3
  •  0
  •   Tester101    16 年前

    看起来mailitem对象有一个 Save 方法,以及 SaveAs 方法。所以你应该可以这样做。

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

    3是以olmsg格式保存消息,请参见 OlSaveAsType Enumeration .

        4
  •  0
  •   Michael    16 年前

    我有一个解决办法。我们决定用密件抄送发送电子邮件的人,然后使用Outlook规则将电子邮件移动到指定的Outlook文件夹。感谢所有回复的人。