473,386 Members | 1,726 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,386 software developers and data experts.

Add Contact to a message being composed

I have created an application to query contact data from an LDAP server and
programtically create a new email to: contacts that had been highlithed by
the user. Now there is a request to add a contact to an email that is
currently be composed. How would one do that. Curently I am just using the
mailto: and piping in the selected users.

Thanks!
Nov 21 '05 #1
10 1640
Hi

I did not understand your scenario very much.
Are you using outlook to compose message programming?
I think we may try to automation outlook to send message programming and
add the recipients in the to field.
Here is a link for you reference.
http://www.visualbasicforum.com/showthread.php?t=216898

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2
OK that code works a little faster than the mailto command but I still have
the problem of adding cc: contacts after the fact.

Scenario:
1. Say I select 4 contacts in the LDAP program and then click on the mailto
button which generates a new email message.
2. Now I go back to the LDAP program and select 2 different contacts. How
would I add them to the cc: of the email that is already being composed?
3. Or say I start composing an email then open the LDAP program and wont to
add user the the email that is already being composed?

Thank you,


""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:4J**************@TK2MSFTNGXA02.phx.gbl...
Hi

I did not understand your scenario very much.
Are you using outlook to compose message programming?
I think we may try to automation outlook to send message programming and
add the recipients in the to field.
Here is a link for you reference.
http://www.visualbasicforum.com/showthread.php?t=216898

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #3
Hi Kenneth,

So far I am researching the issue and I will update you with new
information ASAP.
Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4
Thank you for looking into it, I really appreciate it. No worries about the
confusion it is difficult to explain what I am trying to do.
Once again thank you,
""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:gS**************@TK2MSFTNGXA02.phx.gbl...
Hi Kenneth,

So far I am researching the issue and I will update you with new
information ASAP.
Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #5
Hi

We can use the Outlook automation to get the opened outlook application and
get the current opend mail message editor instance.
e.g.
Dim olApp As Outlook.Application
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
olApp = GetObject(, "Outlook.Application") 'We assume the outlook
application is started, because we are modifying an composing mail message.
Dim mailInspector As Outlook.Inspector = olApp.ActiveInspector 'Get
the mail message editor instance
Dim mi As Outlook.MailItem
mi = mailInspector.CurrentItem 'Get the mailitem
mi.To += ";test;test2"
mi.CC += ";testg;dfd"
mi.BCC += ";testd;fdf"
mi.Recipients.ResolveAll()
End Sub
Here is a link.
Note Because of the Outlook E-Mail Security Update, when you run the
following procedures, you will be prompted several times for permission to
access your e-mail addresses and one prompt to send your message (see the
following screen shots). This is expected behavior. For more information,
see Security Features for Outlook 2002 and Previous Versions.
http://msdn.microsoft.com/library/de...us/dno2k3ta/ht
ml/odc_ac_olauto.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #6
When I use the following code and rem out the 'mi.To += ";test;test2" it
deletes the entries that are already in the To: field. I have tried using
toVal = miTo().toString followed by mi.To += toVal but then the
mailInspector can't find the currentItem.

Any suggestions or links where I can research will be appreciated.

Thank you,
""Peter Huang" [MSFT]" <v-******@online.microsoft.com> wrote in message
news:5b***************@TK2MSFTNGXA01.phx.gbl...
Hi

We can use the Outlook automation to get the opened outlook application
and
get the current opend mail message editor instance.
e.g.
Dim olApp As Outlook.Application
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
olApp = GetObject(, "Outlook.Application") 'We assume the outlook
application is started, because we are modifying an composing mail
message.
Dim mailInspector As Outlook.Inspector = olApp.ActiveInspector 'Get
the mail message editor instance
Dim mi As Outlook.MailItem
mi = mailInspector.CurrentItem 'Get the mailitem
mi.To += ";test;test2"
mi.CC += ";testg;dfd"
mi.BCC += ";testd;fdf"
mi.Recipients.ResolveAll()
End Sub
Here is a link.
Note Because of the Outlook E-Mail Security Update, when you run the
following procedures, you will be prompted several times for permission to
access your e-mail addresses and one prompt to send your message (see the
following screen shots). This is expected behavior. For more information,
see Security Features for Outlook 2002 and Previous Versions.
http://msdn.microsoft.com/library/de...us/dno2k3ta/ht
ml/odc_ac_olauto.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 21 '05 #7
Hi Kenneth,

It is strange.
Based on my test, the code works fine on my side. The To field will keep
its value.

Dim olApp As Outlook.Application
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
olApp = GetObject(, "Outlook.Application")
Dim mailInspector As Outlook.Inspector = olApp.ActiveInspector
Dim mi As Outlook.MailItem
mi = mailInspector.CurrentItem
mi.CC += ";test1;test2"
mi.BCC += ";test3;test4"
mi.Recipients.ResolveAll()
End Sub

Can you post the exact code you are using at your side?

Also have you closed or select anoher item in the outlook?
You may try to set a breakpoint in the code above to run the code line one
by one to monitor the mi.To's value.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #8
Below is the code I am using. I have also tried replacing mVal with
";test1;test2" like your example and got the same results, it clears the To:
field.
Thanks

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim regSub, mailCmd, regSub2, mailCli, regVal1, regVal2, mList,
curCell As String
Dim mVal, mailApp, ProgF, mailParse1, mailParse2, mailParse3,
dilimVal, curLN As String
Dim sqlDelet As New OleDb.OleDbCommand("DELETE Employees.* FROM
Employees", Me.OleDbConnection1)
Dim Exists As Boolean
Dim response As MsgBoxResult
Dim reg As RegistryKey
Dim IsEmpty As Boolean
' Add the folowing "Enabled for Outlook clients ONLY! Cc: selected
contacts." to the tooltip for this button.
dilimVal = ";"
ProgF =
System.Environment.GetFolderPath(Environment.Speci alFolder.ProgramFiles) &
"\"
mList = ProgF & "NCST\LDAPToolSetup\mailList.txt"
If Exists = False Then
System.IO.File.Create(mList).Close()
End If
If Me.DataSet11.Employees.Count = 0 Then
MsgBox("The datagrid is empty, please perform a search!",
MsgBoxStyle.OKOnly, "Error!")
GoTo NoData
End If
Dim WriteVal As New System.IO.StreamWriter(mList)
For x As Integer = 0 To DataSet11.Employees.Count - 1
If Me.DataGrid1.IsSelected(x) = True Then
curCell = DataGrid1.Item(x, 3)
If Not curCell = "" Then
Else
curLN = DataGrid1.Item(x, 1)
MsgBox("You have selected a contact with the last name
""" & curLN & """ that has no email address. The operation is being
canceled! Please de-select the contacts without email addresses and try
again!", MsgBoxStyle.Critical Or MsgBoxStyle.OKOnly, "WARNING!")
WriteVal.Close()
GoTo NoData
End If
WriteVal.Write(curCell & dilimVal)
Else
End If
Next
WriteVal.Close()
Dim readVal As New System.IO.StreamReader(mList)
mVal = readVal.ReadToEnd
readVal.Close()

'Add contacts to Cc: of the existing email message beign compsed.
'Try
Dim olApp As Outlook.Application
olApp = GetObject(, "Outlook.Application")
Dim mailInspector As Outlook.Inspector = olApp.ActiveInspector
Dim mi As Outlook.MailItem
mi = mailInspector.CurrentItem
mi.CC += mVal
mi.Recipients.ResolveAll()
NoData:
End Sub
Nov 21 '05 #9
I have noticed that if you initiate the composing of an email from my
program it performs correctly i.e. adds the selected contacts to the CC:
field and doesn't erase the To: field. If you generate a new email via
Outlook and then use my program to add contacts to the CC: field it erases
the To: field.
"Kenneth H. Young" <yo***@ncst.nrl.navy.mil> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Below is the code I am using. I have also tried replacing mVal with
";test1;test2" like your example and got the same results, it clears the
To: field.
Thanks

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim regSub, mailCmd, regSub2, mailCli, regVal1, regVal2, mList,
curCell As String
Dim mVal, mailApp, ProgF, mailParse1, mailParse2, mailParse3,
dilimVal, curLN As String
Dim sqlDelet As New OleDb.OleDbCommand("DELETE Employees.* FROM
Employees", Me.OleDbConnection1)
Dim Exists As Boolean
Dim response As MsgBoxResult
Dim reg As RegistryKey
Dim IsEmpty As Boolean
' Add the folowing "Enabled for Outlook clients ONLY! Cc: selected
contacts." to the tooltip for this button.
dilimVal = ";"
ProgF =
System.Environment.GetFolderPath(Environment.Speci alFolder.ProgramFiles) &
"\"
mList = ProgF & "NCST\LDAPToolSetup\mailList.txt"
If Exists = False Then
System.IO.File.Create(mList).Close()
End If
If Me.DataSet11.Employees.Count = 0 Then
MsgBox("The datagrid is empty, please perform a search!",
MsgBoxStyle.OKOnly, "Error!")
GoTo NoData
End If
Dim WriteVal As New System.IO.StreamWriter(mList)
For x As Integer = 0 To DataSet11.Employees.Count - 1
If Me.DataGrid1.IsSelected(x) = True Then
curCell = DataGrid1.Item(x, 3)
If Not curCell = "" Then
Else
curLN = DataGrid1.Item(x, 1)
MsgBox("You have selected a contact with the last name
""" & curLN & """ that has no email address. The operation is being
canceled! Please de-select the contacts without email addresses and try
again!", MsgBoxStyle.Critical Or MsgBoxStyle.OKOnly, "WARNING!")
WriteVal.Close()
GoTo NoData
End If
WriteVal.Write(curCell & dilimVal)
Else
End If
Next
WriteVal.Close()
Dim readVal As New System.IO.StreamReader(mList)
mVal = readVal.ReadToEnd
readVal.Close()

'Add contacts to Cc: of the existing email message beign compsed.
'Try
Dim olApp As Outlook.Application
olApp = GetObject(, "Outlook.Application")
Dim mailInspector As Outlook.Inspector = olApp.ActiveInspector
Dim mi As Outlook.MailItem
mi = mailInspector.CurrentItem
mi.CC += mVal
mi.Recipients.ResolveAll()
NoData:
End Sub

Nov 21 '05 #10
Thanks for your followup and the new information Kenneth,

We'll look further into this to see whether there is anything else we've
missed. Meanwhile if you got any
other findings, please feel free to post here also.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 21 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Jason | last post by:
I'm struggling with this email code and I'm not php freak since I'm starting to learn php stuff. Could use some help... It seems that I get too many parse errors all over and cannot figure went...
4
by: Jerry | last post by:
I am trying to create a contact using CDO 1.21. I was wondering if anyone had any sample code of how they may have done this. I am having trouble findinf documentation on how this is done. I...
1
by: Kenneth H. Young | last post by:
I have written an LDAP application that allows user to select contacts from the search result data-grid and then click on an email to button which generates a new email and populates the To: field...
5
by: the_jos | last post by:
Dear reader, I am trying some things with xml/xsl and cannot find a solution for what I would like to do. I have 2 base items with name and price and two that are composed of base two (given...
1
by: paolazi | last post by:
HI I have a flash templates..that uses php as well now I have a problem with my contact page as follows: the user enter his name, email and message into flash input whose Var are: your_name,...
0
by: Derek Moore | last post by:
Hi any one help with this one below is the "contact.php form" and the contents of the "button "from with in flash! but all i get back is the field names but no content any ideas??? contact.php...
4
by: thanos | last post by:
Hello, I'm relatively new to PHP so I found this free contact us script on the net that i was going to use for my Contact Us php page. Its works pretty good except for error handling. I was...
8
by: chromis | last post by:
Hi, I'm writing a contacts section for a cms on a website, I've decided to write the section in OO code. So far I have my Contacts object and a page structure I would use for a procedural site. ...
5
by: krasman | last post by:
hi everyone, i hope you might help me on this one. i need to create a contact in a exchange public folder using dotnet (vb or c#) and exchange 2003, without using outlook object model. i'm...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.