?
Solved

Sending e-mail using ASP & MAPI

Posted on 2005-04-07
2
Medium Priority
?
450 Views
Last Modified: 2008-03-17
I borrowed from code found here: http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_11046024.html

I am trying to understand how to send an e-mail using ASP & MAPI.

<%
LocalServer = "MyServerName"
LocalMailBox = "MyMailbox"
toemail = "myemail@mydomain.com"
ActMsgTo = "dontunderstandthisfield"
subjecttext = "Test"
bodytext = "This is a test"

Dim objSession As Object ' MAPI.Session
    Dim objOutbox As Object ' MAPI.Folder
    Dim objNewMessage As Object ' MAPI.Message
    Dim objRecipients As Object ' MAPI.Recipients
    Dim objOneRecip As Object ' MAPI.Recipient

            Set objSession = CreateObject("MAPI.Session")
            objSession.Logon profileinfo:=LocalServer & vbLf & LocalMailBox, nomail:=True
            Set objOutbox = objSession.Outbox
            Set objNewMessage = objOutbox.Messages.Add
            Set objRecipients = objNewMessage.Recipients
            Set objOneRecip = objRecipients.Add
            With objOneRecip
                .Name = toemail
                .Type = ActMsgTo
                .Resolve ' Get MAPI to determine complete E-mail address.
            End With
            With objNewMessage
                .Subject = subjecttext
                .Text = bodytext
                .Send
            End With
%>

I don't understand the purpose of: ActMsgTo

I tried just using my username.

When I open the page I get: HTTP 500 - Internal server error

What do I need to do to make this work?
0
Comment
Question by:lpenrod
2 Comments
 
LVL 3

Author Comment

by:lpenrod
ID: 13731962
0
 
LVL 15

Accepted Solution

by:
deighc earned 2000 total points
ID: 13734383
First of all, turn off "friendly error messages" so you get better error messages than "500 internal server error".

Second, in VBScript you don't dim as variable as an object type. So this:

Dim objNewMessage As Object

will error. It should simply be:

Dim objNewMessage

Thirdly, all objects that come from the "MAPI.<class name>" namespace come from the CDO 1.2 .dll. Your code will only work if this .dll is installed on your system. This is no longer part of a standard installation of any version of Windows or Office. The easiest way to install this component is to install Outlook with a custom installation configuration and make sure the "Collaboration Data Objects" options is selected.

And to answer your question: the Type property of the recipient object specifies whether the recipient is a 'To', 'CC' or 'BCC' recipient. The values you set are 1 (for To), 2 (for CC) or 3 (for BCC).
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question