473,508 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you add attachments to MailObject?

55 New Member
When I try to add attachments using this method:
public void sendMail_VendorsWithEmail(string TO,string SUBJECT,string ATTACHMENTS)
{
/*this method creates an outlook email object
* attaches a file to it and email it out to the apporpriate vendor with emails
*/
string body=this.getEmailBody();
//creating oulook application class
Application outlook_app = new ApplicationClass();

//creatin message item
MailItem mail_msg = (MailItem)outlook_app.CreateItem(OlItemType.olMail Item);

//email fields
mail_msg.To = TO;
mail_msg.Subject = SUBJECT;
mail_msg.Body = body;
mail_msg.Attachments=ATTACHMENTS ;


//sending email
mail_msg.Send();

}
I get the following error msgs:
Property or indexer 'Microsoft.Office.Interop.Outlook._MailItem.Attach ments' cannot be assigned to -- it is read only Outlook_EmailSender_App

Cannot implicitly convert type 'string' 'Microsoft.Office.Interop.Outlook.Attachments'

what am I doing wrong?
Jun 24 '08 #1
1 1130
Plater
7,872 Recognized Expert Expert
Well the error message states that you are trying to use a string object as Attachments, when it expects an instance of:
Microsoft.Office.Interop.Outlook.Attachments

Try correcting the error it gives you and see where that gets you?
Jun 24 '08 #2

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

Similar topics

1
2322
by: nabil m | last post by:
hi i have 5 checkboxes i would like to when the user click on 1 or multiple checkbox i would like to email 1 or multiple files attachments to them ex: mailMsg.Attachments.Add(myAttachment+i); but...
6
2340
by: ManningFan | last post by:
I'm looking for a list of what the MailObject can do. Basically, can I extract a sender's email address from an email using it. I know I can get the SenderName, To, Subject, Body and SentOn (date...
1
399
by: Steve Holden | last post by:
I'm having some trouble getting attachments right for all recipients, and it seems like Apple's mail.app is the pickiest client at the moment. It doesn't handle attachments that both Thunderbird...
130
3228
by: Gianni Mariani | last post by:
Attached example CPP files makes it easier to post code and extract code from posts. It's unimaginable at this time where virtually any news reader is capable of dealing with attachments to stick...
0
7326
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
7498
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...
1
5053
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...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
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...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
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...

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.