ASP Code
  Home arrow ASP Code arrow Page 4 - Inbox and Outbox Manipulation in ASP
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP CODE

Inbox and Outbox Manipulation in ASP
By: Burhan Khan
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 191
    2005-02-22

    Table of Contents:
  • Inbox and Outbox Manipulation in ASP
  • CDO is not everything
  • Receiving Email: Inbox
  • Inbox using CDO

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Inbox and Outbox Manipulation in ASP - Inbox using CDO


    (Page 4 of 4 )

    You can also see these email messages by using ASP. A Session object is considered a top-level object, meaning it can be created directly from a MS VB program. The Session object contains session-wide settings and options. Microsoft's CDO (Collaborative Data Object) allows you to process this incoming email as a series of objects. First you need to create an instance of CDONTS.Session. It can be created like this:

       objSession = Server.CreateObject("CDONTS.Session")

    An application using the CDO for NTS Library binds by address to the mailbox you specify in the LogonSMTP parameters:

       objSession.LogonSMTP "User Name", "user@example.com"

    When CDO for NTS is running with IIS, the Inbox is a common folder shared by all recipients and applications, and containing all undeleted messages received by IIS. After these two steps, you can use properties ( ".inbox," ".outbox," ".version," etc…) of CDONTS.Session object to get your desired results.

    ' open the inbox folder

    Set objInbox = objSession.Inbox

    ' retrieve the messages collection

    Set strMessages = objInbox.Messages

    ' Go to specific message

    Set strMessage = strMessages(intMsgID)

    ' retrieve message information

    strMessage.Subject                       ' subject of message

    strMessage.Sender                        ' sender

    strMessage.Text                           ' actual message

    After all, you need to log off your CDONTS session by using the ".LogOff" method.

    objSession.LogOff

    That is all the work you need to do to receive email from ASP code.

    To review, the whole code needed to check the inbox in ASP is:

    <%

    'create our variables

    Dim objSession , strMessage , strMessages , objInbox , intMsgID

    'create an instance of the CDONTS.Session object

    Set objSession = Server.CreateObject("CDONTS.Session")

    'this is your logon details

    objSession.LogonSMTP "password" , "email@youraddress.com"

    'open the inbox folder

    Set objInbox = objSession.Inbox

    'retrieve the messages collection

    Set strMessages = objInbox.Messages

    intMsgID = Trim(Request.QueryString("MsgId"))

    If ("" = intMsgID Or Not IsNumeric (intMsgID)) Then

    'display all the messages

    For Each strMessage in strMessages

    i = i + 1

    Response.Write "<a href="""

    Response.Write Request.ServerVariables("SCRIPT_NAME")

    Response.Write "?MsgId=" & i & """>" & strMessage.Subject

    Response.Write "</a>"

    Response.Write " sent by : " & strMessage.Author

    Response.Write "<br>"

    Next

    Else

    Set strMessage = strMessages(intMsgID)

    Response.Write "Subject : " & strMessage.Subject & "<br>"

    Response.Write "Sender : " & strMessage.Sender & "<br>"

    Response.Write "Message : " & strMessage.Text

    End If

    'log off from the session

    objSession.LogOff

    %>

    In this code MsgId is a query string value which shows that you want to see any specific email message. If MsgId is not given in the URL, then all of the emails’ subjects will be shown, so you can select any email.

    Conclusion

    Sending and receiving email from Web pages is obviously useful because you often cannot use Outlook Express or other mail programs such as Eudora and Amoel to receive emails. This may be because you are far from your computer, in another city or country, or enjoying your trip or away with family and friends for the holidays. Using a Web page for sending and receiving email can help you access your email throughout the world.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Why are you talking about the NT4 update?Sheezeesss... who's still running that...
       · 2000 and XP are also NT bassed OS.By NT4 means, 2000 or XP (Service pack 4...
       · Saying "NT4" is *NOT* the same as saying "Windows 2000 with service pack...
       · hi this is thoma, just a month before i started my career in ASP. here i...
       · So why don't you contribute instead of berating someone else who has taken the time...
     

    ASP CODE ARTICLES

    - ASP Forms
    - ASP: The Beginning
    - Getting Remote Files With ASP Continued
    - Inbox and Outbox Manipulation in ASP
    - Relational DropDownList Using VB.NET
    - Ad Tracking URL Hits
    - Use ViewState to display one record per page...
    - Send Email using ASP.NET formatted in HTML
    - ASP File Explorer
    - ASP/XML Interview questions by Srivatsan Sri...
    - Various methods of setting Date values to a ...
    - Conditional DataGrid Item and using checkbox...
    - Fill .NET Listbox with SQL DataReader
    - Filling Dropdown box using Code-Behinds in C#
    - FLAMES code sample written in .NET What is F...

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT