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

Attach form attachment to outlook message

Below code is attached with a button on my infopath form. It does work (
auto populates "To:" and "Subject" based on form nodes) but how can I attach
the file to the message which is attached to attachment control to the form?

Thanks

public void Email_Clicked(object sender, ClickedEventArgs e)

{
XPathNavigator docFM = this.CreateNavigator();

string attachName = docFM.SelectSingleNode("/my:myFields/my:txtSubject",
this.NamespaceManager).Value;

XPathNavigator docFT = this.CreateNavigator();

string msgTo = docFT.SelectSingleNode("/my:myFields/my:EmailTo",
this.NamespaceManager).Value;

Outlook.Application outlookApp = new Outlook.Application();

Outlook.MailItem message =
(Outlook.MailItem)outlookApp.CreateItem(Outlook.Ol ItemType.olMailItem);

message.Subject = attachName;

message.To = msgTo;

message.Body = "This is a test.";

message.Display(false);

outlookApp = null;

}}
Jul 23 '08 #1
1 2678
Looks like I need message.Attachments.Add (sSource, object Type, object
Position, object DisplayName)

If I do:

String sSource = @"C:\abc.txt", it gets attached to the message.

How can I set "sSource" value bases on "attachName" form field?

String sSource = @"C:\ + attachName + .txt" ???


"andyoye" <an*****@nospam.comwrote in message
news:Oz**************@TK2MSFTNGP03.phx.gbl...
Below code is attached with a button on my infopath form. It does work (
auto populates "To:" and "Subject" based on form nodes) but how can I
attach the file to the message which is attached to attachment control to
the form?

Thanks

public void Email_Clicked(object sender, ClickedEventArgs e)

{
XPathNavigator docFM = this.CreateNavigator();

string attachName = docFM.SelectSingleNode("/my:myFields/my:txtSubject",
this.NamespaceManager).Value;

XPathNavigator docFT = this.CreateNavigator();

string msgTo = docFT.SelectSingleNode("/my:myFields/my:EmailTo",
this.NamespaceManager).Value;

Outlook.Application outlookApp = new Outlook.Application();

Outlook.MailItem message =
(Outlook.MailItem)outlookApp.CreateItem(Outlook.Ol ItemType.olMailItem);

message.Subject = attachName;

message.To = msgTo;

message.Body = "This is a test.";

message.Display(false);

outlookApp = null;

}}


Jul 23 '08 #2

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

Similar topics

15
by: tabonni | last post by:
Hi I try to grab the checked files from HTML page and then send those PDF files as attachments. It can just send email, there are no PDF files attached. Can anybody point out my error? My...
3
by: Wizard | last post by:
In Access, using VBA, I am sending emails based on query results. These email include relevant information to a scheduled event the recipient is assigned to. This is working great. What I have...
9
by: bobdydd | last post by:
Hullo Everybody I am trying to send a email from WITHIN Access 2000 with a report attached that is generated WITHIN Access in the normal way, but all the help examples I have seen uses an...
6
by: David Anderson | last post by:
Does anyone know how to drag&drop a message with attachments from Outlook (2002 or 2003) in to a VB.Net windows form. This is really stumping me. I've spent a fair amount of time trying to find a...
12
by: cj | last post by:
What's the parameter (like ?attachment) or something.
1
by: Mr T | last post by:
I know how to send email from Access and I know how to create a custom form in Outlook. but.... How do I put the email info from Access into the Outlook custom form ??? Dim MyDB As Database Dim...
0
by: mmatchyn | last post by:
How do I attach an outlook email message as an attachment within another outlook email message. Right now I am using the following code. But I was wondering if there is a better way to do this...
2
by: MyWaterloo | last post by:
I have a database that I’ve created for creating/printing/sending purchase orders. It works great! Long live Access! Although, I have a slight problem with the sending part. I have a table for my...
0
by: sandeep98811 | last post by:
I am getting following weird issue, "When forwarding an email with an open attachment the user warned twice that an attachment is open". I am catching Forward event of mail item in function...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.