Solved

Sending email from an VB.net web application and Lotus notes

Posted on 2004-09-22
9
1,477 Views
Last Modified: 2013-12-18
Hi

I need to send an email from my web application. I am using vb.net  to develop my web application. The corportae uses Lotus notes to send email. I will be have lotus notes client installed on the web server.
Could you please show me some examples how to send email.
Also any input on setting the environment will be a help. (example does the lotus notes server need to support SMTP).

Thanks
Madhavi
0
Comment
Question by:ChanderMadhavi
9 Comments
 
LVL 14

Assisted Solution

by:p_partha
p_partha earned 175 total points
ID: 12124349
You have to use Com
Make sure you have notes installed

SOmethign in this lines:
Dim session As New NotesSession
            Dim db As Domino.NotesDatabase
            Dim doc As Domino.NotesDocument

            session = CreateObject("Lotus.NotesSession")
            session.Initialize("arsenal13")

            db = session.GetDatabase("mail/servers/companyA", "mail/bloggsj.nsf")

            If Not db.IsOpen() Then
                db.Open()
            End If

            doc = db.CreateDocument
            doc.ReplaceItemValue("Form", "Memo")
            doc.ReplaceItemValue("SendTo", Recipient)
            doc.ReplaceItemValue("Subject", Subject)
            doc.ReplaceItemValue("Body", Body)
            doc.SaveMessageOnSend = True
            doc.Send(False)
            doc.Save(True, False) ' If required
0
 
LVL 1

Assisted Solution

by:yangshuhua
yangshuhua earned 175 total points
ID: 12124374
Here it is:
1.    Add Domino as Reference to you vb.net application
2. Add following code:
        Dim dmObj as Domino.NotesSession
        Dim Maildb As Domino.NotesDatabase 'The mail database
        Dim MailDbName As String 'THe current users notes mail database name
        Dim MailDoc As Domino.NotesDocument 'The mail document itself
        Dim rti As Domino.NotesRichTextItem
        Dim mailItem As Domino.NotesItem
     
        ' Create and Initialize Notes Session
        dmObj = New Domino.NotesSession()
        dmObj.Initialize("")

        ' set which user email as sender email and its mail database name
        MailDbName = "mail\someone.nsf"

        'Open the mail database in notes
        'If Maildb Is Nothing Then

        Maildb = dmObj.GetDatabase(serverName, MailDbName)
        If Maildb.IsOpen = false Then
            Maildb.OpenMail()
        End If

        'Set up the new mail document

        MailDoc = Maildb.CreateDocument()
        mailItem = MailDoc.ReplaceItemValue("Form", "Memo")
        mailItem = MailDoc.ReplaceItemValue("SendTo", receiver)
        mailItem = MailDoc.ReplaceItemValue("CopyTo", copyToreciver)
        mailItem = MailDoc.ReplaceItemValue("BlindCopyTo",blindCopyToReceiver)
        mailItem = MailDoc.ReplaceItemValue("Subject", Subject)
       
        ' add body
        rti = MailDoc.CreateRichTextItem("Body")
        ....
        MailDoc.Save(False, True)
        MailDoc.Send(True)
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 150 total points
ID: 12124661
Both sets of code above are essentially identical.  But, there's one problem:

  dmObj.Initialize("") -- assumes no password for Notes
          session.Initialize("arsenal13") -- assumes a particular password

Make sure you put in the correct password for teh ID file for the Notes client you haveinstalled.



More problems:

         db = session.GetDatabase("mail/servers/companyA", "mail/bloggsj.nsf")

This gets a particular mail file from which to send mail.  You will need to choose the correct mail file.  (Technically, any file can send mail, as long as you are not saving a copy of the sent message.  So, it does not have to be the mail file associated with the user ID on the web server.)

Similarly:

       MailDbName = "mail\someone.nsf"

        'Open the mail database in notes
        'If Maildb Is Nothing Then

        Maildb = dmObj.GetDatabase(serverName, MailDbName)
There is an assumed MailDbName, and serverName is undefined.

This may not work -- I think vb.net requires the SET keyword in front of object assignment.  You could just drop the mailItem = part of it, as he result of replaceItemValue can be discarded.
        mailItem = MailDoc.ReplaceItemValue("Form", "Memo")

Content -- text versus rich text.  Partha showed how to set up a plain text BODY field.  Yangshuhua showed how to set up rich text.  Very important missing piece:
        rti = MailDoc.CreateRichTextItem("Body")
        ....
        MailDoc.Save(False, True)


The rti= (probably should also have SET) creates a rich text container, but you still have to provide content!  Look into rti.appendNewLine(1) and rti.appendText("Text to append").  Or, you could set up BODY as a plain text item instead of a rich text message, in which case, set the text the same way Form,SendTo,CopyTo,BlindCopyTo, and Subject were set up.

receiver/recipient -- for teh SendTo field -- for a single address, this can be a string.  For multiple addresses, it should be an array.  (You can also use a single element array for a single address, to make it consistent.)  Ditto copyToreceiver and blindCopyToReceiver
0
 
LVL 14

Expert Comment

by:p_partha
ID: 12133369
any updates on this ?

Partha
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12134165
Ah! My seniors here missed something subtle.

(1) I need to send an email from my web application.
(2) I will be have lotus notes client installed on the web server.

Please address these issues in order to be eligible for points. Or should I do it :)


>> Also any input on setting the environment will be a help. (example does the lotus notes server need to support SMTP).

Madhavi, that's two questions for the price of one. Remember, to get better quality, spend more money :)
0
 

Author Comment

by:ChanderMadhavi
ID: 12136480
Could you please address the above  issues. I have no problems increasing the points to 750 as far as I get my answers.

Thanks
Madhavi
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 12137504
Well, the limit is 500pts/question, but who cares?

Point (2) -- I thought you eant there already IS a client installed.  If not, you will need to install either server or client.  SPeak to the Domino administrator about what can be done.  You probably want to have a Notes ID unique to the web server.

Domino can natively support SMTP.  If you are already working in a Domino mail environment, then whatever client or server you set up for your web server, it will be able to take advatage of the DOmino SMTP infrastructure that is already there.

If you are not already in a Domino environemnt, of course, I wonder why you would set all this up just to send messages.
0
 
LVL 14

Expert Comment

by:p_partha
ID: 12137531
Ranjeet
am not sure what we didn't answer here. We answered to whatever was asked

Partha
0
 

Expert Comment

by:ramanathan_m
ID: 12143161
Even I feel all the questions have been answered by the experts in parts.

> I need to send an email from my web application. I am using vb.net  to develop my web application. The corportae uses Lotus notes to send email.  I will be have lotus notes client installed on the web server.

So, you already have Lotus Domino environment. So, you need not install any special servers to send messages from your custom applications. Just ask your Mail administrator to create a mail-id for your application (though it is not a requirement - it is a good practice to have a separate ID for applications). Install a Lotus Client and connect to *any* Domino mail server (At the time of ID file creation itself, your mail server would have been defined by the administrator).

Could you please show me some examples how to send email.

Refer the code above and also good suggestions from qwaletee.

Also any input on setting the environment will be a help. (example does the lotus notes server need to support SMTP).

This also has been answered. Domino natively supports not only SMTP, but almost any known mail standards and protocols. Being the industry leader in mail, you need never worry about support for any standards as far as mail is concerned. Otherwise, your organization would not have gone with Lotus Domino ;-)

You can also format your mails using all rich text formatting, and send your mails as HTML mail with links to specific documents.

Just a sample --

Dim richText As New NotesRichTextItem(doc, "Body")
Dim richStyle As NotesRichTextStyle
Set richStyle = session.CreateRichTextStyle
richStyle.NotesFont = FONT_COURIER
richStyle.FontSize = 12
richStyle.Bold = True

-- whatever formatting you want, make it
-- Then, append the style object to the body of E-Mail like this

Call richText.AppendStyle(richStyle)

I do not know what else you expect to be answered, unless you make the questions clear.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now