473,663 Members | 2,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(o bject sender, ClickedEventArg s e)

{
XPathNavigator docFM = this.CreateNavi gator();

string attachName = docFM.SelectSin gleNode("/my:myFields/my:txtSubject",
this.NamespaceM anager).Value;

XPathNavigator docFT = this.CreateNavi gator();

string msgTo = docFT.SelectSin gleNode("/my:myFields/my:EmailTo",
this.NamespaceM anager).Value;

Outlook.Applica tion outlookApp = new Outlook.Applica tion();

Outlook.MailIte m message =
(Outlook.MailIt em)outlookApp.C reateItem(Outlo ok.OlItemType.o lMailItem);

message.Subject = attachName;

message.To = msgTo;

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

message.Display (false);

outlookApp = null;

}}
Jul 23 '08 #1
1 2688
Looks like I need message.Attachm ents.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******** ******@TK2MSFTN GP03.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(o bject sender, ClickedEventArg s e)

{
XPathNavigator docFM = this.CreateNavi gator();

string attachName = docFM.SelectSin gleNode("/my:myFields/my:txtSubject",
this.NamespaceM anager).Value;

XPathNavigator docFT = this.CreateNavi gator();

string msgTo = docFT.SelectSin gleNode("/my:myFields/my:EmailTo",
this.NamespaceM anager).Value;

Outlook.Applica tion outlookApp = new Outlook.Applica tion();

Outlook.MailIte m message =
(Outlook.MailIt em)outlookApp.C reateItem(Outlo ok.OlItemType.o lMailItem);

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
3703
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 idea is: When people check the check boxes in HTML page for the PDF files, it will transfer the files' name to ASP page. Then, it will attach it in the email.
3
4757
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 been ask to do now is to include an attached file, that when opened will be an Outlook Calendar event and when saved the event will be added to the recipient's calendar in Outlook. These files are .vcs files. I am able to create the necessary...
9
1850
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 external file like C:\test.txt I have been using: DoCmd.SendObject acReport, stDocName, acFormatRTF, But when the message body is more than 70 characters long (random), it
6
14668
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 solution on the internet, with limited success. I do have code to drag an attachment directly from Outlook to a form, but not a whole message. I want to have access to an object reprensenting the message so I can bust out the message and...
12
2771
by: cj | last post by:
What's the parameter (like ?attachment) or something.
1
5951
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 MyRS As Recordset Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment
0
1281
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 without using a file that needs to be deleted later. private MailMessage addAttachment(MailMessage Mail, MailItem item) { string path "Messages\\message" + message_id+ ".MSG";
2
2607
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 suppliers that I pull some of the fields from to include in my main form for creating the purchase order. One of the fields is an email field that I have set as a hyperlink. If I click it and there is an email address in it then a new outlook email...
0
1738
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 _mail_Forward(). Steps to reproduce issue: 1. Open email , open attachment 2. Click on Forward Button, 3. Outlook displays message "The attachment "test" is open or in use by another application. If you continue, you will lose any changes you...
0
8436
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8634
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.