VBA : choose mailbox and send mail from Excel?

Hi to all,

I have a simple to send an email from Excel :

======================================

Private Sub Lotus_SimpleAndWorking()

Dim Session As Object

Dim Dir As Object

Dim Doc As Object

Dim Workspace As Object

Dim EditDoc As Object





'Creation of a memo in Lotus Notes

Set Workspace = CreateObject("Notes.NotesUIWorkspace")

Set Session = CreateObject("notes.NOTESSESSION")

Set Dir = Session.GetDatabase("", "")



Call Dir.OPENMAIL



'Creation d'un document

Set Doc = Dir.CreateDocument



    Doc.form = "Memo"

    Doc.Subject = "my subject"

    Doc.SendTo = "to whom it may concen"

    Doc.body = "some body"





'Display the Mail in Lotus Notes

Set EditDoc = Workspace.EditDocument(True, Doc)

Set Session = Nothing

Set Dir = Nothing

Set Doc = Nothing

Set Workspace = Nothing

Set EditDoc = Nothing

End Sub

======================================

It’s sending email from my personal account (mail\Mail2\965203.nsf).

But i want to send email from another account. An account used by several people including me.

For that purpose i’ve change that line :

Set Dir = Session.GetDatabase(“”, “”)

By this one :

Set Dir = Session.GetDatabase(“Notes://PARFMB003/SERVERS/GROUP”, “mail\Mail4\paitproffi.nsf”)

It’s not bugging, but it doesn’t change anything : it’s still sending the mail from my personal account.

What shall i do so it take into account that information : “paitproffi.nsf” (and not use this information i didn’t give : “965203.nsf”) ?

Thank you for your help !!!

Fred

Subject: Try

Setting up a location doc for that other mail file and ID and swithch to that location prior to running the vb

Subject: Working !

Hi Barry,

It’s working !! Thanks for your help !!!

That solution is fine for me and i can definitely use it that way.

But it would be even more clean to not have to set up a location doc on each computer using this VBA code (The VBA code should be enough).

There is really no way for VBA to tell Lotus which mailbox to use ?

Thanks again !!

Subject: Nope

The vba uses the location doc. So you will need the location doc. Setting them up can be done thru lotusscript button or even possibly vba.

You might be able to change the location= in the Notes.ini to the new location doc and change it back to what was there at the start in your vba code

Subject: Cool

Thanks again for those new advices, they are workable solutions.

Thanks a lot !