473,322 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

E-mail Attachments - Mapisend

3
I am facing issues while adding attachments in an E-mail via Mapisend. The code I use is below. If I try to send , I am getting error messgae in Mailmessage.12. Mailmessage.12 is expected as numeric, I do not know what should it be. If I Provide '0', it is throwing out error. Can any one help what shoudl I do to fix this. I am able to send E-mail sucessfully without Attachments..

Code (Please refer comments near Mailmessage.12)

OPTIONS "WINFUNC NOSOURCE C_CALL"
NUMERIC DIGITS 10
/* ============== FUNCDEF some needed OS functions =========== */
DO
/* Register the Windows OS function MAPISendMail(), callable as SendOneEMail */
MapiRecipDesc = "32u, 32u, str *, str *, 32u, void"
MapiMessage = "32u, str *, str *, void, str *, void, 32u, struct MapiRecipDesc *, 32u, struct MapiRecipDesc *, 32u, void"
FUNCDEF("SendOneEMail", "32u, void, void, struct MapiMessage, 32u, 32u", "mapi32", "MAPISendMail")
/* Register the Windows OS function MAPILogon() */
FUNCDEF("MAPILogon", "32u, void, str, str, 32u, 32u, void stor", "mapi32")
/* Register the Windows OS function MAPILogoff() */
FUNCDEF("MAPILogoff", "32u, void, void, 32u, 32u", "mapi32")
CATCH FAILURE
CONDITION("M")
RETURN
END
/* ====================== Send an email ===================== */
/* Log on (to the internet). We need to do this before sending email.
* This will bring up a connection requester for the email
* client if the user is not yet connected to the internet.
* The first arg is a handle to some window you've opened. Omit this
* if you haven't opened a window. If you have no window, then any
* dialog presented (such as a connection dialog) is modal -- that is,
* the user will have to operate it before he can access another program
* on his computer. So, it's best to open a REXX Dialog window and use
* RXQUERY "HANDLE" to get a handle.
** The second arg is a profile name string, limited to 256 characters or
* less. This is the profile to use when logging on. If you omit this
* arg or pass an empty string, and the fourth (flags) arg is not 1,
* then MAPILogon() displays a logon dialog box with an empty name field.
*
* The third arg is the password, limited to 256 characters or less. If
* the messaging system does not require a password, or if it requires
* that the user enter it, then omit this arg or pass an empty string.
* When the user must enter a password, you must add in 1 to the fourth
* arg (flags) to allow a logon dialog box to be displayed.
*
* The fourth arg is a flags (numeric) value. It can be any of the following
* added together:
* * 1 = A logon dialog box should be displayed to prompt for logon information.
* If the user needs to provide information to enable a successful log on,
* this value must be added in.
* 2 = An attempt should be made to create a new session rather than acquire
* the environment's shared session. If this value is not added in, an
* existing shared session is used.
* 8 = Make this a shared session.
* 16 = Don't use the default profile.
* 32 = Extended MAPI Logon.
* 4095 = An attempt should be made to download all of the user's messages
* before returning. If this is not added in, messages may be downloaded in
* the background after the call returns.
* 8192 = Do logon UI in all email accounts.
* 131072 = Display password dialog only.
* 1048576 = Minimal wait for logon.
*
* The fifth arg can be omitted.
* The sixth arg is the name of the REXX variable were you want the MAPI
* "session handle" stored. This will be passed to other MAPI functions.
*/
err = MAPILogon(, , , 1 + 8 + 4095, , Session)
IF err == 0 THEN DO
/* Initialize email structure */
MailMessage.1 = 0
/* Subject line on the email */
MailMessage.2 = "Subject line - Test mail"
/* Email text body. It can be as long as you like, with as many lines as you want */
MailMessage.3 = "Here is the message body of the email" || '0D0A'x || "Line #2"
MailMessage.4 = 0

/* Set the time that the email was sent. The format is Year/2-digit month/2-digit day, * followed by a space, and then Hour:2-digit minute. */
PARSE VALUE TIME('N') WITH hour ':' min ':' .
MailMessage.3 = LEFT(DATE('S'), 2) || DATE('O') hour || ':' || min
MailMessage.5 = LEFT(DATE('S'), 2) || DATE('O') hour || ':' || min

MailMessage.6 = 0

MailMessage.7 = 1 /* Add 2 if a read receipt is requested */

/* Set the originator (ie, the person sending the email) */
MailMessage.8.1 = 0
MailMessage.8.2 = 0
MailMessage.8.3 = "Bambi@com" /* Display name of person sending email */
MailMessage.8.4 = "Bambi@com" /* email address of person sending email */
MailMessage.8.5 = 0
MailMessage.8.6 = 0

/* Set the recipient (ie, the person receiving the email). Note: We send one email, but* you could alternately specify numerous people to which to send the email. You'd have to FUNCDEF the MapiMessage so that the second "struct MapiRecipDesc was actually an array such as "struct MapiRecipDesc[10] *" to send to 10 email addresses. For example, here's how to send the same email to two people:*
* MapiMessage = "32u, str *, str *, void, str *, void, 32u, struct MapiRecipDesc *, 32u, struct MapiRecipDesc[2] *, 32u, void"
*
* MailMessage.9 = 2;
* MailMessage.10.1.1 = 0
* MailMessage.10.1.2 = 1
* MailMessage.10.1.3 = "Jeff Glatt" /* Display name of first person receiving the email */
* MailMessage.10.1.4 = "jglatt@borg.com" /* email address of first person receiving the email */
* MailMessage.10.1.5 = 0
* MailMessage.10.1.6 = 0
* MailMessage.10.2.1 = 0
* MailMessage.10.2.2 = 1
* MailMessage.10.2.3 = "Mr Peabody" /* Display name of second person receiving the email */
* MailMessage.10.2.4 = "someone@somewhere.com" /* email address of second person receiving the email */
* MailMessage.10.2.5 = 0
* MailMessage.10.2.6 = 0
*/
MailMessage.9 = 1;
MailMessage.10.1 = 0
MailMessage.10.2 = 1
MailMessage.10.3 = "Bambi@com" /* Display name of person receiving the email */
MailMessage.10.4 = "Bambi@com" /* email address of person receiving the email */
MailMessage.10.5 = 0
MailMessage.10.6 = 0

/* Count of attached files. We don't send attachments here. If you wanted to send
* attachments, you'd have to FUNCDEF the MapiMessage so that the last void was
* actually an array such of "struct MapiFileDesc *". For example, to send 2 attachments: */

MapiFileDesc = "32u, 32u, 32, str *, void, void"
MapiMessage = "32u, str *, str *, void, str *, void, 32u, struct MapiRecipDesc *, 32u, struct MapiRecipDesc *, 32u, struct MapiFileDesc [2] *"
MailMessage.11 = 0
MailMessage.12.1.1 = 0
MailMessage.12.1.2 = 0
MailMessage.12.1.3 = -1
MailMessage.12.1.4 = "C:\Program Files\Reginald\Rexx\bytsep.txt" /* Full path to first attached file */
MailMessage.12.1.5 = 0
MailMessage.12.1.6 = 0
MailMessage.12.2.1 = 0
MailMessage.12.2.2 = 0
MailMessage.12.2.3 = -1
MailMessage.12.2.4 = "C:\Program Files\Reginald\Rexx\bytsep.txt" /* Full path to second attached file */
MailMessage.12.2.5 = 0
MailMessage.12.2.6 = 0
MailMessage.12 = 0 /***************** I am gettting error because of this parameter */
/* How should this code be converted to add the attachment */

/* Send the email.
*
* First arg is the session handle from MAPILogon.
*
* Second arg is the handle to your window. Omit this if you have no window.
*
* Third arg is the name of the variable that has your initialized MapiMessage struct.
*
* The fourth arg is a flags (numeric) value. It can be any of the following
* added together:
*
* 1 = A logon dialog box should be displayed to prompt for logon information
* if required. If this is not added in, the application does not display a
* logon dialog box and returns an error if the user is not logged on.
*
* 2 = An attempt should be made to create a new session rather than acquire
* the environment's shared session. If this value is not added in, an
* existing shared session is used.
*
* 8 = A dialog box should be displayed to prompt the user for recipients and
* other sending options. If this is not added in, at least one recipient must be
* specified in your MapiMessage struct.
*/
err = SendOneEMail(Session, , MailMessage, 1)
IF err \== 0 THEN SayMAPIErrMessage(err, "Sendmail failed:")

FINALLY
/* Log out
*
* First arg is the session handle from MAPILogon.
*
* Second arg is the handle to your window. Omit this if you have no window. */
MAPILogoff(Session)
END
ELSE SayMAPIErrMessage(err, "Problem logging into MAPI:")

/* Done */
RETURN
SayMAPIErrMessage:
SELECT ARG(1)
WHEN 1 THEN SAY "User aborted."
WHEN 3 THEN SAY "There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed."
WHEN 4 THEN SAY "Can't save attachment because disk is full."
WHEN 5 THEN SAY "Need more memory to send/receive email."
WHEN 6 THEN SAY "Access denied."
WHEN 8 THEN SAY "The user has too many sessions open simultaneously."
WHEN 9 THEN SAY "Too many attachments."
WHEN 10 THEN SAY "Too many recipients."
WHEN 11 THEN SAY "Attachment not found."
WHEN 12 THEN SAY "Can't open an attachment."
WHEN 13 THEN SAY "Can't save an attachment to a temporary file."
WHEN 14 THEN SAY "A recipient did not appear in the address list."
WHEN 15 THEN SAY "Recipient name is specified incorrectly."
WHEN 16 THEN SAY "No messages."
WHEN 17 THEN SAY "Invalid message ID."
WHEN 18 THEN SAY "The text in the message was too large to send."
WHEN 19 THEN SAY "Invalid session."
WHEN 20 THEN SAY "Type not supported."
WHEN 21 THEN SAY "A recipient was specified more than once."
WHEN 22 THEN SAY "Message in use."
WHEN 23 THEN SAY "Network failure."
WHEN 25 THEN SAY "Invalid recipients."
OTHERWISE SAY ARG(2) err
END
RETURN
Nov 1 '06 #1
0 3753

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: LutherRevisited | last post by:
Is there a way I can put a message together without having to download any attachments there may be at the same time. I'm not having any problems dealing with attachments, but the way I'm doing...
6
by: ErwinF | last post by:
Hi there, I would like to know the following: How to send send email attachments using WebDAV in VB .NET? Sample code please................... Thanks for your help.
2
by: Joe George | last post by:
Hi there, How to save email attachments, from exchange, using WebDAV in C#.NET? Sample code please................... Thanks for your help. -- Joe George
2
by: David Veeneman | last post by:
My web app creates several temporary files, then attaches them to an email that it sends out. When the app attches the documents to the email, .NET locks the files. My problem is that they aren't...
0
by: jackiewkc | last post by:
Hi, Does anyone know how to use VB to write a simple MAPI to save email attachments from a specified email address to my hard drive? What I basically want is that everytime when I receive an...
3
by: olafmol | last post by:
Hello, i want to write a PHP4 script that reads POP3 or IMAP mail and can decode the possible attachments in the email. I've looked around for some classes to do this, and found a few, but most...
1
by: shil | last post by:
Is there any possible way to create an email attachments from an URL in windows vb.net application? I'm using frame work 2.0, System.Net.Mail component. If I attach a file from my file system,...
0
by: =?Utf-8?B?amVhbm9mbWlubmVhcG9saXM=?= | last post by:
I am having problems opening email attachments when I receive as a Notepad. I have this problem in AOL or Outlook. When I open I get a box with letters, symbols and numbers. I have been told as...
1
by: rottmanj | last post by:
So after a few hours of playing with my config file, I think I have it to a point where I am ready to start adding in the rest of the components to my perl application. One thing that I know I need...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.