Send an email from access via Lotus iNotes installed on intranet - email

I just need to be pointed in the right direction, on how
to send an email using VBA. I have Lotus as an email system which is embedded into our intranet system.
As a try, this code prepares an email and send it via Lotus (installed on pc) :
Dim ns As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim sender, recipient As String
'sender = Forms![LogIn]![TxtEmail]
If (Not IsNull(DLookup("Email", "Users", "UserName ='" & Me.Affectation.Value & "'"))) Then
recipient = DLookup("Email", "Users", "UserName ='" & Me.Affectation.Value & "'")
MsgBox "recipient *" & recipient & "*"
Else
MsgBox " recipient null"
End If
If Not (ns Is Nothing) Then
Call ns.InitializeUsingNotesUserName("CN=MyuserName/O=Cmpany", "password")
Set db = ns.GetDatabase("ServerName", "mail\MyuserName.nsf", False)
If (Not (db Is Nothing)) Then
Set doc = db.CreateDocument()
doc.Form = "Memo"
doc.SendTo = recipient
doc.subject = "Email Subject"
Dim rt As NotesRichTextItem
Set rt = doc.CreateRichTextItem("Body")
rt.AppendText ("Body text")
doc.Send (False)
Set rt = Nothing
Set doc = Nothing
MsgBox "Message Sent."
Else
MsgBox "db Is Nothing"
End If
Set db = Nothing
Set ns = Nothing
Else
MsgBox "ns Is Nothing"
End If
My question here is how set this code to make the target Lotus the one on our intranet: my login is such "39398C#mycompany.com" and the application is accessed by "http://mail.mycompany.com/mail/username.nsf..."

Unfortunately this is not possible this way. This "embedded" Lotus Notes as you call it is a simple website. It is called "iNotes" and does not have any dlls installed on your client (unless you install the ActiveX control for IE, but that does not help anything with your problem).
For sending eMails via iNotes you need a complete new method and you need your Domino administrator to help you with it: You could either use a webservice to send your mail (this has to be enabled on the server) or you can use DIIOP (again: DIIOP- Task has to be loaded on server).
To at least compose an email, you could use the mailto: protocol, but you need to set iNotes to be your mailto- protocol- handler:
Open Internet Explorer browser and log into iNotes (http://mail.mycompany.com/mail/username.nsf). Please note that this option is not available at this time to Firefox browser users.
Click the "Preferences" button located in the top right corner.
Find "Default Mail Client" section on the "Basics" tab of the iNotes preferences.
Click the button "Make Default".
Using this approach you cannot send the mail directly but need the user to press "Send".

I am not sure what you mean by "I have Lotus as an email system which is embedded into our intranet system".
You need the Notes client installed locally to be able to use COM in your own code. Use the ID file (must be local in the Notes Data directory) for your corporate account amd point to the server on the network for your mailfile.
But you can't point your program to a iNotes instance on a web server, it has to be on a Domino server accessed with a Notes client.
What you could do is to create a new web application on the server, where you have an agent that will read HTTP POST data, create an email and send it out.
Then you simply make a HTTP post from your application.
Here are a couple of blog entries I wrote that might help you:
http://blog.texasswede.com/free-code-class-to-read-url-name-value-pairs/
http://blog.texasswede.com/parse-url-in-domino-agent/

You should probably change your code to send mail via SMTP instead of using the Notes API objects. Microsoft provides an object model called CDO that I think will help you. See the answer to theis question for details. You will just need the hostname or IP address information to connect to a Domino server in your infrastructure that supports inbound SMTP.

Not sure about it, because that code is pretty old as we know use Outlook and I haven't use it in a long while, but that might be some insight :
I seem to remember that if you add doc.From = ns.CommonUserName, this will choose your session automatically!
And the full code :
Dim session As Object
Dim db As Object
Dim doc As Object
Dim attachme As Object
Dim EmbedObj As Object
Dim attachment() As String
Dim i As Integer
Set session = CreateObject("notes.notessession")
Set db = session.GetDatabase("", "")
Call db.OPENMAIL
Set doc = db.CreateDocument
With doc
.Form = "Memo"
.sendto = MailDestinataire
'.copyto = MailDestinataire2
.Subject = Sujet
.Body = CorpsMessage
.From = session.CommonUserName
.posteddate = Now
.SaveMessageOnSend = True
End With

Related

New Email Dialogue in Outlook

Is it possible to create a new email with redemption and open outlook new email dialogue, without outlook running.
I know how to create an email, is it just a case of creating the temporary email save it as an msg, then process start, or can I achieve this via another method.
Dim Session As RDOSession = RedemptionLoader.new_RDOSession
Dim Msg = Session.GetMessageFromMsgFile(strPath & "" & strFilename, True)
Msg.MessageClass = "IPM.Note"
You can, just call RDOMail.Display(true/false) (true for for modal display). Keep in mind that MAPI forms used to show the message are implemented by outlook.exe, so it will launch anyway if it is not running.
You can create new items without Outlook running on the system (but it should be installed with a mail profile configured, or at least the MAPI runtime should be installed):
' create a new session
Dim Session As RDOSession = RedemptionLoader.new_RDOSession
Session.Logon
Set Folder = Session.GetDefaultFolder(olFolderInbox)
Set Msg = Inbox.Items.Add("IPM.Note")
Msg.BCC = "eugene#astafiev.vvv"
Msg.Subject = "test"
Msg.Display()

Send mails from Notes - when it is not used for mail

Ok, in these times when some people move from Lotus Notes to Office 365 I have come across a certain requirement...
An older workflow application sends mail to users. This has worked fine for ages. But now we have a new type of users. These users are just using Notes for a couple of old legacy applications like the one in question.
The error we get is:
File does not exist
And the code that generates it is pretty simple:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim rtitem As NotesRichtextItem
Dim doc2 As NotesDocument
Set db = session.CurrentDatabase
Set doc2 = New NotesDocument(db)
doc2.Form = "Memo"
doc2.Subject = "Test mail " & now
Set rtitem = New NotesRichTextItem (doc2, "Body" )
Call rtitem.AppendText("A simple test....")
Call rtitem.addnewline(2)
Call rtitem.AppendText("Link to complaint ")
Call doc2.Replaceitemvalue("sendto", "john#dalsgaard-data.dk")
doc2.Send( False )
It fails when running the last line....
So, the question really is: How can I code around the this issue?
I know there is no mail file for the user - and I would really prefer not to have to create one for the new users.
Thanks in advance!
/John
Error will appear when user triggering the code doesn't have a mail file specified in person document/location. One option would be to change code to save the new mail directly to server mail.box (assuming server is configured to route mails) or just send the email directly through SMTP using java.
Ok, I have done some trial & error testing on this....
Conclusion so far is that it works in this situation:
In the LOCAL location document (in names.nsf on the computer) you specify:
Mail server - as a server the user can reach
Mail "On Server"
An existing mail file - it can be ANY existing file on the server, it doesn't have to be a mail database.
Actually, a non-conclusive test indicates the mail database even doesn't have to exist (but the user with the setup for testing had to leave - so I couldn't confirm this tonight...)
Edit:
Further testing indicates that this may not be a problem if the user is NOT roaming. I need some further verification that this is actually the reason why I got it working (for one thing you cannot remove the mail file name again once added)... But thought I would add it here.

Check if CDO e-mail is supported on Volusion Windows server

I am trying to use CDO to send e-mail through a Volusion Windows server. The ASP script I've written works fine on a GoDaddy Windows server so I know the script is correct but it doesn't work through Volusion. In that script, I had used GoDaddy's relay-hosting.secureserver.net SMTP server to send the e-mail and it worked great on the GoDaddy server but not on Volusion.
I've tried several SMTP servers. Volusion provides documentation on their mail servers here:
https://support.volusion.com/article/connecting-my-volusion-e-mail-account
I've tried both the SMTP servers with SSL and without in the script (and have also tried all the different ports).
I'm wondering if the ability to send e-mails with CDO is not supported on Volusion servers? Is there a way to check if a server supports CDO without having access to the cPanel, WHM or any core files? With Volusion, they only give you access to part of the FTP.
Thanks for your help!
EDIT
Here is the code I used that worked:
<%
sendUrl="http://schemas.microsoft.com/cdo/configuration/sendusing"
smtpUrl="http://schemas.microsoft.com/cdo/configuration/smtpserver"
' Set the mail server configuration
Set objConfig=CreateObject("CDO.Configuration")
objConfig.Fields.Item(sendUrl)=2
objConfig.Fields.Item(smtpUrl)="relay-hosting.secureserver.net"
' Server port (typically 25)
objConfig.Fields.Update
' Create and send the mail
Set myMail=CreateObject("CDO.Message")
' Use the config object created above
Set myMail.Configuration=objConfig
myMail.From="test#test.com"
myMail.To="test#test.com"
myMail.Subject = "Test Subject"
myMail.HTMLBody = "Test"
myMail.Send
Set myMail = Nothing
response.write "Success!!"
%>
I've obviously updated those e-mail address when I run the code.
EDIT
To answer a question in the comments my server version is:
Microsoft-IIS/6.0
To answer your initial question, how to check CDO is supported.
Here is a quick example of checking for the Object Required error (or any error for that matter while instantiating the CDO COM object.
Dim cdo, is_cdosupported
On Error Resume Next
Err.Clear
Set cdo = Server.CreateObject("CDO.Configuration")
is_cdosupported = (Err.Number <> 0)
On Error Goto 0
If is_cdosupported Then
Call Response.Write("CDO is supported")
Else
Call Response.Write("CDO not supported")
End If
Digging around on Google
After commenting a few times decided to dig into Volusion (must admit not one I've come across and after a quick search in Google found this link.
Quote from The VSMTP Key
A special ASP class is provided for use with Volusion's built-in send-mail component, VSMTP.
You can use this class to create your own send mail solutions for your store using ASP. Note that the information being provided in this article is intended for advanced users. This solution provides an alternate to sending email via Volusion's standard POP-based or webmail-based solutions.
If you're using Volusion's standard email hosting resources (POP, IMAP, or Webmail), you will not be required to update any functions within your store or my.volusion.com account.
To use the VSMTP component with your Volusion store, you will need to download Volusion's VSMTP ASP class.
Judging by the Object Required ASP component error you get when trying to instantiate the CDO components I would say that CDO is not supported by Volusion servers.
There is a simple example shown using the VSMTP ASP class
<%
Dim mailer
Set mailer = new vsmtp
mailer.VsmtpKey = "65539C7A-525C-4CB7-B36B-BFBBDD332DD6"
mailer.EmailSubject = "Test Subject"
mailer.EmailFrom = "test#testdomain.com"
mailer.EmailTo = "test#testdomain.com"
mailer.TextBody = "Hello World!"
mailer.HTMLBody = "Hello World"
mailer.AddAttachment Server.MapPath("/v/test1.txt")
mailer.AddAttachment "/v/test2.txt"
mailer.Send()
%>
Your best bet is to adapt your existing script to use this VSMTP bespoke class that is support by Volusion.
Looking at the VSMTP ASP class, it looks like it's a simple wrapper to POST to an ASP endpoint (vsmtp.asp).
<%
Class vsmtp
Public VsmtpKey
Public EmailSubject
Public EmailFrom
Public EmailTo
Public TextBody
Public HTMLBody
Private Attachment
Private AttachmentFolder
Public Sub AddAttachment(ByRef FilePath)
If AttachmentFolder = "" Then
AttachmentFolder = Server.MapPath("/v")
End If
If StrComp(Left(FilePath,Len(AttachmentFolder)),AttachmentFolder,vbTextCompare) = 0 Then
FilePath = Replace(Mid(FilePath,Len(AttachmentFolder)-1),"\","/")
End If
If StrComp(Left(FilePath,3),"/v/",vbTextCompare) <> 0 Or InStr(FilePath,",") > 0 Then
Err.Raise 512, "vsmtp.AddAttachment", "Invalid Attachment Path"
End If
If IsEmpty(Attachment) Then
Attachment = FilePath
Else
Attachment = Attachment & "," & FilePath
End If
End Sub
Public Sub Send()
Dim HTTPRequest
Set HTTPRequest = CreateObject("WinHTTP.WinHTTPRequest.5.1")
HTTPRequest.Open "POST", "http://" & Request.ServerVariables("LOCAL_ADDR") & "/vsmtp.asp", False
HTTPRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HTTPRequest.SetRequestHeader "Host", Request.ServerVariables("SERVER_NAME")
HTTPRequest.Send _
"VsmtpKey=" & Server.URLEncode(VsmtpKey) &_
"&Subject=" & Server.URLEncode(EmailSubject) &_
"&FromEmailAddress=" & Server.URLEncode(EmailFrom) &_
"&ToEmailAddress=" & Server.URLEncode(EmailTo) &_
"&Body_HTML=" & Server.URLEncode(HTMLBody) &_
"&Body_TextOnly=" & Server.URLEncode(TextBody) &_
"&Attachment_CSV=" & Server.URLEncode(Attachment)
If HTTPRequest.ResponseText <> "True" Then
Set HTTPRequest = Nothing
Err.Raise 8, "vsmtp.Send", "Unable to send email. Check logs for details."
End If
Set HTTPRequest = Nothing
End Sub
End Class
%>
Short answer, you cannot. You will get an error message that states Access is denied. VSMTP is the only alternative to sending email directly from Volusion, however, you can only send from their SMTP servers and the options (e.g. Headers) are limited to what is provided.

Why is a memo created and sent from a LotusScript agent converting rich text to plain and removing document links?

We have a Document Library set up to accept user administration requests from our managed school districts. I recently made some updates to the form used to enter requests and some minor changes to the agent used to notify our administrators of the new request. Since these changes, the notification emails, which were once being received in rich text with an embedded document link, are now coming in as plain text. I have reverted both the form and the agent to previous versions and email message remains plain text. The agent's code follows.
Option Public
Use "Variables"
Dim db As NotesDatabase
Sub Initialize
On Error Goto gotError
Set s = New NotesSession
Dim doc As NotesDocument
Dim kbaseDb As NotesDatabase
Dim kdoc As NotesDocument
Set db = s.CurrentDatabase
Set doc = s.DocumentContext
Dim fromName As NotesName
Dim commName As String
Set fromName = s.CreateName(doc.from(0))
commName = fromName.Common
Dim memo As New NotesDocument(db)
Dim body As NotesRichTextItem
memo.Form = "Memo"
memo.SendTo = techEmail
memo.Subject = doc.categories(0) + " admin request from " + districtName
If doc.priorityflag(0) = "Priority" Then
memo.Subject = doc.Categories(0) + " PRIORITY admin request from " + districtName
memo.DeliveryPriority = "H"
End If
Set body = memo.Createrichtextitem("Body")
Call body.AppendText("Please process this " + doc.action(0) + " request from " + commName + ".")
Call body.AddNewLine(2)
Call body.AppendText("Comment: " + doc.comment(0))
Call body.AddNewLine(1)
Call body.AddNewLine(1)
Call body.AddNewLine(1)
Call body.AppendText("Link to request ")
Call body.AppendDocLink( doc, "Link to request ")
Call memo.send(False)
Call doc.ReplaceItemValue("OwnerNotified", doc.Owner)
Call doc.Save(True, False)
Exit Sub
gotError:
Print "<b><FONT color=red>System Error (" + Str(Err) + "): " + Error
Exit Sub
End Sub
It seems like it's something to do with the signer of the agent- unless somehow your reversion to the original agent hasn't worked.
Here's a set of things I woudl check :
Identify the person who the agent is running as. It's usually the signer, or web user if it's a web agent and "Run as web user" is ticked on the agent properties.
Check their entry in the NAB. If they have their mail system NOT set to Notes, then the server's email sending settings must come into action when sending on their behalf - check the server document in the NAB, under MTAs .. Message Content field. I believe this tells the server how to send such emails.
If this is the issue, then fixes would be :
* Sign the agent with another Id who uses Notes Mail
* If you can't sign with another Id, set the email system of the signer to Notes Mail
Fingers crossed..
The fix was to change the "Message Content" setting for outbound MIME conversion. This is set to "Convert from Notes to plain text" by default and needed to be changed to "Convert from Notes to HTML".
Details are on this page in the InfoCenter:
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.help.domino.admin.doc%2FDOC%2FH_SPECIFYING_MIME_CONVERSION_OPTIONS_OVER.html

Outlook 2007: Create a message rule that detects autoforwarded messages and handles them

I'm looking for kind of the opposite of creating a rule to auto-forward
emails. I want to create a rule that acts on RECEIVED auto-forwarded emails,
but not any that were manually forwarded or replied to by the same person.
E.g. Jim forwards me all emails with "blah" in the subject, and I want to
move those auto forwards to my "Jim's auto-forwards" folder, but if he
forwards me a message manually that says "blah" but he adds his own comments,
I want it to stay in my inbox.
Outlook seems to know that it is auto forwarded, as it shows up
as such when you view the email. Just above the "From" section but
just below the ribbon, it says something like:
"This message was AutoForwarded."
However I haven't found any option to create a rule filtering these.
Our exchange server (Outlook maybe?) adds the following headers when auto-forwarding:
Auto-Submitted: auto-generated
X-MS-Exchange-Generated-Message-Source: Mailbox Rules Agent
(Visible by opening an email and viewing the message "Properties" to see the headers) These appear to be what Outlook is using to detect that a message was AutoForwarded (or at least coincide)
And Outlook/Exchange 2013 has the filter option "with specified words in the message header"
I have used a rule that looks similar to the following to successfully move only "blah" subject messages autoforwarded from "Jim" to a specific folder:
Apply this rule after the message arrives
from 'jim#example.com'
and with 'blah' or 'blurg' in the subject
and with 'auto-generated' or 'Auto-Submitted' in the message heade
move it to the 'Jims auto-forwards' folder
And this has appeared to prevent any that he's manually forwarded from being processed by the same rule.
Our Exchange Server adds the following header for Auto Forwarded and Auto Replies
X-MS-Exchange-Inbox-Rules-Loop: abc#company.com
where abc#company.com is the email of the person auto forwarding the email.
I use MS Outlook 2010 in which i have setup a rule ->
From: abc#company.com
and with 'X-MS-Exchange-Inbox-Rules-Loop: abc.xyz#company.com'
or 'X-MS-Exchange-Inbox-Rules-Loop: abc.XYZ#company.com' in the message header
move it to the 'xyz' folder
i have checked abc.xyz#company.com as well as abc.XYZ#company.com in message header as in some auto Fwd/Re email header the Lastname of the sender was uppercase.
Note: as mentioned before this rule applies to all Auto Forwarded and Auto Replies (e.g Out of office/ vacation auto replies) from that person. Manual Fwd/RE emails are not filtered
I do not think rules can do this.
Try some VBA. untested
Edit 2013 02 26
Put the code in ThisOutlookSession http://www.slipstick.com/outlook-developer/how-to-use-outlooks-vba-editor/
Here are some references so you can debug if necessary.
NewMailEx: http://msdn.microsoft.com/en-us/library/office/bb147646(v=office.12).aspx
AutoForwarded Property: http://msdn.microsoft.com/en-us/library/office/ff867162.aspx
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim varEntryIDs
Dim objItem
Dim i As Integer
Dim myOlApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
varEntryIDs = Split(EntryIDCollection, ",")
For i = 0 To UBound(varEntryIDs)
Set objItem = Application.Session.GetItemFromID(varEntryIDs(i))
'Debug.Print "NewMailEx " & objItem.Subject
If objItem.SenderName = "Jim Smith" Then
If objItem.AutoForwarded then
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
' Assumes destination folder is directly under the Inbox
Set myDestFolder = myInbox.Folders("Jim AutoForwarded")
objItem.Move myDestFolder
End If
End If
Next
Set objItem = Nothing
Set myDestFolder = Nothing
Set myInbox = Nothing
Set myNameSpace = Nothing
End Sub