VB6 with MAPI for Lotus Notes - vb6

Everybody,
I need to incorporate mail functionality into a VB6 application. The default mail system is Lotus Notes 6.5. I have read that this version of Lotus Notes is MAPI-enabled.
Here is a weird thing I see. When the user clicks a SendMail button, the below code is launched:
MAPISession1.SignOn
With MAPIMessages1
.SessionID = MAPISession1.SessionID
.Compose
.RecipAddress = "John Smith"
.MsgSubject = "Test memo"
.MsgNoteText = "This is testing data!"
.AddressResolveUI = True
.ResolveName
.Send True
End With
This code opens a window in Lotus Notes (this is what I expected) but
- the To address box contains the recipient address followed by the body text on the first line and the recipient address on the second line:
John SmithThis is testing data!
John Smith
-- the Body section is blank.
Is there anything I can do to fix it or Lotus Notes is incompatible with MAPI.
Thanks,
Lev

I don't have access to the appropriate tools, so I can't test this, but try moving the .ResolveName line up right after you set the recipient address, like so:
.Compose
.RecipAddress = "John Smith"
.ResolveName
Lotus Notes is compatible with Simple MAPI, not full (extended) MAPI, but the code you're using appears to be Simple MAPI.

I did a quick bit of research and supposedly Simple MAPI is supported in Lotus Notes 6. However, a little more digging led me to this post where someone had trouble using MAPI in r6, and opted to use COM instead. I've only worked with COM, but I can say it does give you a lot of flexibility if you're up for changing your code.

Related

How to send an email using VBScript without CDO

I can't send email with VBScript because the Cdo resources have been removed.
For example, this line of code does not work because when I open the link, I see that the resource has been removed:
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"
On Microsoft's site it says: "This content is no longer actively maintained."
https://learn.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2003/ms873037(v=exchg.65)
Is there any way to send an email using VBScript where the code doesn't need this kind of reference?

Windows SendTo from script

I'm writing an application where I have to send an email with an attachment using the default mail application.
Before the email is sent, I want the user to be able to edit the text, i.e. the application should just open the mail client with pre-filled recipient and attachment and give the user the opportunity to send it.
At very minimum I need the same effect I'd got if I selected "SendTo/Mail Recipient" from the context menu of the file.
Solutions based on the "mailto:" trick won't work as there are mail clients that do not support the "attachment=" part.
The most complete solution I've found is this one:
http://www.codeproject.com/Articles/3839/SendTo-mail-recipient
but it seems a lot of code for something so simple! (and also crashes when compiled with VS2008)
Is there any other option? It would be ok even if it was an external tool or script (e.g. a .vbs script to be launched with cscript).
I would advise you to use MAPI (Messaging Application Program Interface).
If dotNet can be part of the solution, here's a ready-to-use class in C# : Class for creating MAPI Mail Messages. It would give you something like this:
MapiMailMessage message = new MapiMailMessage("Test Message", "Test Body");
message.Recipients.Add("Test#Test.com");
message.Files.Add(#"C:\del.txt");
message.ShowDialog();
Otherwise, you can always do it in C++ if you feel confortable with it, like this answer suggest.
Then, you will be able to ShellExecute the binary executable and pass it some parameters.
Hope this helps :-)

Rails 3.1 - Devise inserting address into subject line of confirmation email

I'm using rails 3.1 with Devise. When an account confirmation email goes out, it is received with the following subject line:
Subject: [["test13#test.com"]]MySite Account Confirmation Instructions
I've modified the corresponding entry in config/locals/devise.en.yml like this:
mailer:
confirmation_instructions:
subject: 'MySite Account Confirmation Instructions'
I don't want the '[["test13#test.com"]] in the email subject line. How can I get Devise to not put it there? BTW I really don't want to have to create some custom mailer that overrides Devises' stock mailer... Big extra bonus points for an answer that avoids anything to do with custom mailers. But if that is the only way, I need to know that too...
My guess is that the [["test13#test.com"]] should actually only show up in development mode, since that's the format of ActionMailer's DevelopmentMailInterceptor (see the notes in RailsCast 206)
The email address between brackets indicates the address to which the email would have been sent on production. It instead sends it to you at an email specified in your DevelopmentMailInterceptor.
The mail subject is generated in Devise::Mailers::Helpers.headers_for (source code here), so the most straightforward way would be monkey-patching this method.
This was a strange one... Had to reboot my Mac, after which the problem was gone.

What's wrong with this Applescript?

My app has some rudimentary applescriptability. There is one method (receivedInstantMessage) that takes a single parameter (message) and passes it to my app which then processes it.
The following applescript:
tell application "MyApp"
receivedInstantMessage "This is a message"
end tell
Works perfectly. My app presents a dialog containing the message ("This is a message").
I'm trying to set it up so that when I send an IM to iChat, it runs an applescript that will send the contents of the message to my app. I have told iChat to run a script when a message is received and I know that part is working. The script I am now using does not work:
using terms from application "iChat"
on message received theMessage from theBuddy for theChat
tell application "MyApp"
receivedInstantMessage theMessage
end tell
end message received
end using terms from
Nothing happens when I receive a message. Even if I substitute the message variable (theMessage) from iChat and use an arbitrary string it still does nothing.
What am I doing wrong. I'm quite new to applescript (being a REALbasic coder normally).
[Update]: This seems to work now. A simple restart of the Mac fixed things. Very odd...
just a semantic detail: Consider the scripter is sending messages to your app, not receiving them. Yes, your app is receiving them, but the terminology you chose "receivedInstantMessage" is from the point of view of your app, not the scripter.
Additionally, it is considered naff to have terminology in camel case. AppleScript terminology can (and often should) contain spaces. And if you really want to do it properly you should separate the terminology into nouns and verbs. (Where nouns are properly-modelled objects, with properties, and verbs are commands for manipulating them. In this case you probably want something like send message "bla", where a message is an object with properties like sender, recipient, channel etc. and send is a command which takes a message object as a parameter - check the dictionary of Snak for a quite nice - but not perfect - implementation).
Sorry if this sounds anal. I have been applescripting for many years, and while I really appreciate it when developers add applescript support, I know I speak for all applescripters when I say that poorly constructed dictionaries, and poor terminology choices are frustrating and irritating, especially as the app gets more mature and the developer starts to say things like "I know the applescript interface needs a complete overhaul but I don't want to break existing scripts!". ALL applescripters prefer it if the scripting interface gets better, even if it breaks existing scripts. So: Do it wrong now, but be prepared to fundamentally improve it later. :)
Even Apple has some lousy terminology, for example in iTunes there is an updatePodcast and updateAllPodcasts command. This is just wrong, according to their own technote 2106 - pay particular attention to the section on naming rules.. They should have a podcast object and an update command, so that you could also do things like "delete every podcast whose name contains "Ann Coulter". ("Whose" clauses are one of the coolest features of appleScript!)

Using selenium in order to read emails on gmail

I'm using selenium-rc and I'm trying to click on a specific email on gmail in order to get into the email page. More specifically: on the gmail inbox, click on a email with a specific subject.
I can't find the correct xpath (none of the tags in the email part are links). Ideas?
This XPath should do the trick:
//div[#class = 'y6']/span[contains(., 'subject_here')]
... provided that you've first changed to the canvas_frame frame. Otherwise, it's unlikely it'll work at all. If you're not using Firebug to inspect the HTML, you really should as that's how I found out these values. Also, the Gmail structure changes fairly regularly, so that y6 class could change any day.
I haven't tested this, but this might work for you:
open http://gmail.com
// do the login stuff, click on login
waitForElementPresent canvas_frame
selectFrame canvas_frame
waitForElementPresent //div[#class = 'y6']/span[contains(., 'subject_here')]
clickAt //div[#class = 'y6']/span[contains(., 'subject_here')] 0,0
// do stuff you care about
Important: you have to use clickAt to cause Gmail to realize you're clicking. It doesn't work with just the simple "click" command.
By the way, we do this for our own internal monitoring of Gmail because it's been so unstable over the last few months. We're using my companies Selenium-based free monitoring service, which lets you run Selenium scripts to check performance and functionality of your site.
change gmail to basic html mode.
Is your app a Ruby on Rails one by chance? If so, email spec is a great way to test emails without haveing to mess around with Gmail: http://github.com/bmabey/email-spec
I used this command
clickAt | //table/tbody/tr/td[5]/div[#class='yW'] |
Click at the FROM field of first/recent/top most mail to go to mail detail page. // note: tr for first mail, tr[2] for second and so on.

Resources