MAPI control problem | Familiar Sight | | Join Date: Jan 2008
Posts: 137
| | |
Hi everyone..
i need ur help once more time.... i have a form called reminder..in tht form i have:
txtid, txtcaseid, txtreminder, cmbremindby(system or user), txtremindto, dtpreminddt, MAPISession1, MAPIMessages1, cmdReminder
in this case i have to set some fix reminder and fix date for every month tht automatically send by the system to some particular people...
i dont knw anything abt mapi control and have never used tht...
got some codes from the net bt didnt help me coz in my case the system has to send the reminder..
wld u plz help me with the code and tel me wht should i do?
thank u very much
| | Familiar Sight | | Join Date: Jan 2008
Posts: 137
| | | re: MAPI control problem
is anyone thr to help me out with this????
| | Familiar Sight | | Join Date: Jan 2008
Posts: 137
| | | re: MAPI control problem
Hello everyone..
i need some help here if anyone has any idea, plz share wit me
thanks a lot
|  | Moderator | | Join Date: Dec 2006 Location: Bangalore ,India
Posts: 7,504
| | | re: MAPI control problem
do you want to send those as e-mails ?
| | Familiar Sight | | Join Date: Jan 2008
Posts: 137
| | | re: MAPI control problem
yes i have to send them as a reminder(mail) to some particular people...
|  | Moderator | | Join Date: Dec 2006 Location: Bangalore ,India
Posts: 7,504
| | | re: MAPI control problem
try this sample program. that might help you. -
Private Sub Command2_Click()
-
MAPISession1.SignOn
-
MAPIMessages1.SessionID = MAPISession1.SessionID
-
'Compose new message
-
MAPIMessages1.Compose
-
'Address message
-
MAPIMessages1.RecipDisplayName = "diaplay name here"
-
MAPIMessages1.RecipAddress = "recipient@server.com"
-
' Resolve recipient name
-
MAPIMessages1.AddressResolveUI = True
-
MAPIMessages1.ResolveName
-
'Create the message
-
MAPIMessages1.MsgSubject = "Hi"
-
MAPIMessages1.MsgNoteText = "Test mail"
-
'Add attachment
-
MAPIMessages1.AttachmentPathName = "Path of the file to attach"
-
'Send ethe message
-
MAPIMessages1.Send False
-
MAPISession1.SignOff
-
End Sub
-
| | Familiar Sight | | Join Date: Jan 2008
Posts: 137
| | | re: MAPI control problem
i have tried this code but its not working.... i m getting error for tht mapito
is telling type mismatch... getting error in the bold line
Private Sub CmdReminder_Click()
Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object
Dim mapito As Object
Dim MAPIMessages1 As MAPIMessages
Dim MAPISession1 As MAPISession
'Create the Session Object.
Set objSession = CreateObject("MAPI.SESSION")
'Logon using the session object.
'Specify a valid profile name if you want to.
'Avoid the logon dialog box.
objSession.Logon ProfileName:="Azi"
'Add a new message object to the OutBox.
Set objMessage = objSession.Outbox.Messages.Add
'Set the properties of the message object.
objMessage.Subject = "This is a test."
objMessage.Text = "This is the message text."
'Add a recipient object to the objMessage.Recipients collection.
Set objRecipient = objMessage.Recipients.Add
'Set the properties of the recipient object.
objRecipient.Name = "azita.mostaghni" '<---Replace this with a valid
'display name or e-mail alias
'Type can be ActMsgTo, mapiTo, or CdoTo for different CDO versions;
'they all have a constant value of 1. objRecipient.Type = mapito
objRecipient.Resolve
'Send the message.
objMessage.Send showDialog:=False
MsgBox "Message sent successfully!"
'Logoff using the session object.
objSession.Logoff
End Sub
|  | Moderator | | Join Date: Dec 2006 Location: Bangalore ,India
Posts: 7,504
| | | re: MAPI control problem
TRY THE CODE IN POST #6
that will work for you.
| | Familiar Sight | | Join Date: Jan 2008
Posts: 137
| | | re: MAPI control problem
ok i wil try tht
thank u very much for ur help
| | Familiar Sight | | Join Date: Jan 2008
Posts: 137
| | | re: MAPI control problem
Hi again..
The code which u have given it to me its just composing the message... how can i set the server in this code... i want the system to send the mail automatically to some people.... i have to set the server and set the name of the persons who wil get the reminder automatically from the system..
can u help me in that???
thank u
|  | Moderator | | Join Date: Dec 2006 Location: Bangalore ,India
Posts: 7,504
| | | re: MAPI control problem
you can easily get the list form database and to automate use timer.
| | Familiar Sight | | Join Date: Jan 2008
Posts: 137
| | | re: MAPI control problem
ok i can set the timer and get the name of the persons from database... the main problem is how can i set the server ip address and the port number in the code.. do u have any code sample for tht ?
thank u
|  | Moderator | | Join Date: Dec 2006 Location: Bangalore ,India
Posts: 7,504
| | | re: MAPI control problem
Which server you are talking about ?
The code that i have passed on to You uses outlook to send mails.
Do you use Outlook ?
| | Familiar Sight | | Join Date: Jan 2008
Posts: 137
| | | re: MAPI control problem
i use outlook to send the mail.... bt my reminder has to go to SMTP mail server and from thr it goes to the users.. coz i m not sending the reminder and mail, the system wil send the reminder on a particular date of each month automatically... thts why i need to set the server ip address and the port... i think it should be something like this bt this is for CDO and its not working for MAPI control.. i need to knw how can i set all these for MAPI
With cdoconfig.Fields
.Item(cdoSendUsingMethoD) = 25
.Item(sch & "sendusing") = 80 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "<172.16.1.22>"
.Update
End With
thank u
| | Newbie | | Join Date: Feb 2009 Location: Dublin
Posts: 1
| | | re: MAPI control problem
I have complied the code from #'6 above.
Here is an extract of the statements.
Option Explicit
.
.
.
Dim MAPISession As Object
Dim MAPIMEssages As Object
Dim MAPISession1 As MAPISession
Dim MAPIMEssages1 As MAPIMEssages
.
.
.
Private Sub LogonEmail()
On Error GoTo LogonEmailErr
MAPISession1.SignOn 'Generates error 91.
MAPIMEssages1.SessionID = MAPISession1.SessionID
Exit Sub
LogonEmailErr:
MsgBox ("Error " + Trim(Str(Err)) + " in LogonEmail.")
'etc.
'etc.
End Sub
At the Signon statement I receive error 91 'Object variable or 'WITH' block variable not set'.
So, in order to Set something I added (just before the signon line):
Set MAPISession1 = CreateObject("MAPI.SESSION")
but that causes an error 429: ActiveX component can't create object or return
reference to this object.
If you can assist my inexperience I would be very glad.
Thank you.
| | Newbie | | Join Date: Oct 2009
Posts: 1
| | | re: MAPI control problem
Hi guys,
I've been racking my brain with similar issues related to MAPI, which when working to send e-mails is fairly effective, but is extremely fragile. I kept getting Error Code: 48389 run time errors.
I was having a problem signing in to a session
i.e. Form1.MAPISession1.Action = 1
I broke my legacy code down written by predeccessors about 50 pages long, to finally work out a control in vb6 components called 'DatabaseControl' from 'DatabaseControl.ocx' was conflicting with the MAPI controls. My advice to anyone trying to send an e-mail would be to check thier components - especially this one which will not work inconjunction with MAPI. Its best to replace this control with direct SQL statements to access database instead using ADO.
Below is full procedure used to send e-mails:
Sub SendMail()
'MAPI constants from CONSTANT.TXT file:
Const SESSION_SIGNON = 1
Const MESSAGE_COMPOSE = 6
Const ATTACHTYPE_DATA = 0
Const RECIPTYPE_TO = 1
Const RECIPTYPE_CC = 2
Const MESSAGE_RESOLVENAME = 13
Const MESSAGE_SEND = 3
Const SESSION_SIGNOFF = 2
'Open up a MAPI session:
Form1.MAPISession1.Action = SESSION_SIGNON
'Point the MAPI messages control to the open MAPI session:
Form1.MAPIMessages1.SessionID = Form1.MAPISession1.SessionID
Form1.MAPIMessages1.Action = MESSAGE_COMPOSE 'Start a new message
'Set the subject of the message:
Form1.MAPIMessages1.MsgSubject = "This is the subject."
'Set the message content:
Form1.MAPIMessages1.MsgNoteText = "This is the mail message."
'The following four lines of code add an attachment to the message,
'and set the character position within the MsgNoteText where the
'attachment icon will appear. A value of 0 means the attachment will
'replace the first character in the MsgNoteText. You must have at
'least one character in the MsgNoteText to be able to attach a file.
Form1.MAPIMessages1.AttachmentPosition = 0
'Set the type of attachment:
Form1.MAPIMessages1.AttachmentType = ATTACHTYPE_DATA
'Set the icon title of attachment:
Form1.MAPIMessages1.AttachmentName = "System Configuration File"
'Set the path and file name of the attachment:
Form1.MAPIMessages1.AttachmentPathName = "C:\CONFIG.SYS"
'Set the recipients
Form1.MAPIMessages1.RecipIndex = 0 'First recipient
Form1.MAPIMessages1.RecipType = RECIPTYPE_TO 'Recipient in TO line
Form1.MAPIMessages1.RecipDisplayName = "eddyjawed@yahoo.com" 'e-mail name
'MAPIMessages1.RecipIndex = 1 'add a second recipient
'MAPIMessages1.RecipType = RECIPTYPE_TO 'Recipient in TO line
'MAPIMessages1.RecipDisplayName = "Tanya Lasagna" 'e-mail name
'MAPIMessages1.RecipIndex = 2 'Add a third recipient
'MAPIMessages1.RecipType = RECIPTYPE_CC 'Recipient in CC line
'MAPIMessages1.RecipDisplayName = "BlairAngelHair" 'e-mail name
'MAPIMessages1.RecipIndex = 3 'Add a fourth recipient
'MAPIMessages1.RecipType = RECIPTYPE_CC 'Recipient on CC Line
'MAPIMessages1.RecipDisplayName = "JoanieCannelloni" 'e-mail name"
'MESSAGE_RESOLVENAME checks to ensure the recipient is valid and puts
'the recipient address in MapiMessages1.RecipAddress
'If the E-Mail name is not valid, a trappable error will occur.
Form1.MAPIMessages1.Action = MESSAGE_RESOLVENAME
'Send the message:
Form1.MAPIMessages1.Action = MESSAGE_SEND
End Sub
To get this to work, you need to create a form called form1, add a command button and then the two mapi controls ('session' and 'messages')....
Good luck ;)
|  | Similar Visual Basic 4 / 5 / 6 bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,295 network members.
|