- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am writing a program that runs daily on a remote machine. I would like it to email me when it completes each day's run. It doesn't need to be elaborate, just 1 line of text to a prespecified address through a prespecified smtp server.
I have figured out I will have to use the MAPI functions (mapiSendMail, mapiMessage, etc).
I have two questions before I go any further on this project:
(1) has anyone already done something like this & would they share the code with me?
(2) if not, do interfaces to the mapi functions exist in the win32 api modules included in CVF? If so, where, and if not, does anyone have any suggestions?
Matt.
I have figured out I will have to use the MAPI functions (mapiSendMail, mapiMessage, etc).
I have two questions before I go any further on this project:
(1) has anyone already done something like this & would they share the code with me?
(2) if not, do interfaces to the mapi functions exist in the win32 api modules included in CVF? If so, where, and if not, does anyone have any suggestions?
Matt.
Link Copied
11 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The SEE4F library of SMTP/POP3 routines may be of interest, but this is a commercial product. MAPI seems to be implemented using a C++ class library and/or COM server, and thus doesn't have Fortran interfaces readily available. Maybe the Module Wizard would be able to help.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might consider running your program from a script, then having the script generate the e-mail rather than having your program do this directly.
James
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
James,
at the risk of sounding silly, how do i send an email with a script?
Matt.
at the risk of sounding silly, how do i send an email with a script?
Matt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> MAPI
> seems to be implemented using a C++ class library
> and/or COM server, and thus doesn't have Fortran
> interfaces readily available. Maybe the Module
> Wizard would be able to help.
AFAIK that is not entirely true -- take a look at MAPI.h for example. It seems that MAPI.h defines only stuff compatible with old Windows (i.e. basic e-mail functionality), but that's what OP essentially wants. As I see, it's not translated to Fortran even in 6.6 but since it's a straightforward C header, it should be simple to convert.
Jugoslav
> seems to be implemented using a C++ class library
> and/or COM server, and thus doesn't have Fortran
> interfaces readily available. Maybe the Module
> Wizard would be able to help.
AFAIK that is not entirely true -- take a look at MAPI.h for example. It seems that MAPI.h defines only stuff compatible with old Windows (i.e. basic e-mail functionality), but that's what OP essentially wants. As I see, it's not translated to Fortran even in 6.6 but since it's a straightforward C header, it should be simple to convert.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note that BLAT is also available as a Fortran callable
DLL. Not for the latest version afaik. But works quite well.
Frits.
DLL. Not for the latest version afaik. But works quite well.
Frits.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
fritsv,
In a nutshell, how would I call the .dll? I've never used cross-platform .dll's before. I have the 1.84e release which has all of the files.
I've added the .lib to my project, but I can't find a description of the function in the .dll, nor how I add the dll to the project.
Could you help?
TIA,
matt.
In a nutshell, how would I call the .dll? I've never used cross-platform .dll's before. I have the 1.84e release which has all of the files.
I've added the .lib to my project, but I can't find a description of the function in the .dll, nor how I add the dll to the project.
Could you help?
TIA,
matt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why don't I add a few details:
I have added the interface
INTERFACE
INTEGER(4) FUNCTION SEND(TXT)
!DEC% ATTRIBUTES DLLIMPORT
CHARACTER(LEN=*) TXT
END FUNCTION
END INTERFACE
to the proper place in the calling subroutine. I have added blatdll.dll and blatdll.lib to the list of source files (I can't find anywhere else to put them, and my version of VS seems finicky about letting me open the included project file)
With all this, when I compile my app, I get a LINKER error of unresolved external symbol: -send@8
I am sure that this is a simple oversight, but I'd appreciate any help.
Thanks,
matt.
I have added the interface
INTERFACE
INTEGER(4) FUNCTION SEND(TXT)
!DEC% ATTRIBUTES DLLIMPORT
CHARACTER(LEN=*) TXT
END FUNCTION
END INTERFACE
to the proper place in the calling subroutine. I have added blatdll.dll and blatdll.lib to the list of source files (I can't find anywhere else to put them, and my version of VS seems finicky about letting me open the included project file)
With all this, when I compile my app, I get a LINKER error of unresolved external symbol: -send@8
I am sure that this is a simple oversight, but I'd appreciate any help.
Thanks,
matt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need:
Where you should put an actual exported name instead of "Something" (NB: case-sensitive). You can obtain it using
If it's exactly "_Send@4" you should add
Jugoslav
INTERFACE INTEGER(4) FUNCTION SEND(TXT) !DEC% ATTRIBUTES DLLIMPORT, ALIAS: "Something":: SEND CHARACTER(LEN=*) TXT END FUNCTION END INTERFACE
Where you should put an actual exported name instead of "Something" (NB: case-sensitive). You can obtain it using
dumpbin /exports blatdll.dll. It will probably be "_Send@4" or "_send".
If it's exactly "_Send@4" you should add
!DEC$ATTRIBUTES REFERENCE:: TXTline in the INTERFACE block. (@4 indicates there's only one argument, thus no string length should be passed).
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
...that should be !DEC$, not !DEC% of course.
Btw, I played today with Simple MAPI module (mapi.h -> mapi.f90). Simple MAPI is straightforward C and easily translatable to Fortran -- only gotcha is that dynamic binding is necessary (i.e. no import library is provided).
So, you can find mapi.f90 along with a sample use on my home page.
Jugoslav
Btw, I played today with Simple MAPI module (mapi.h -> mapi.f90). Simple MAPI is straightforward C and easily translatable to Fortran -- only gotcha is that dynamic binding is necessary (i.e. no import library is provided).
So, you can find mapi.f90 along with a sample use on my home page.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here a sample program:
Frits.
Program Example use dfwin, only: loadlibrary,getprocaddress,freelibrary use dflib ! Declare an interface block to the routine to be called. interface integer function send(c) character*(*) c end function end interface character(255) command character(255) line pointer (p,i) pointer (q,send) logical status integer istat line='blat.dll' line=line(1:len_trim(line))//char(0) ! First, locate and load the dll p = loadlibrary(line) if (p == 0) then type *, "Error occurred opening "//line(1:len_trim(line)) call sleepqq(5) type *, "Program aborting" goto 1000 endif ! Set up a pointer to the routine of interest q = getprocaddress(p, "Send"C) if (q == 0) then type *, "Error occurred finding SEND in "//line(1:len_trim(line)) call sleepqq(5) type *, "Program aborting" goto 1000 endif command='... The commandline for Blat ...'//char(0) ! Now call the routine istat=send(command) type *,'Send status:',istat status = freelibrary(p) 1000 stop end
Frits.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page