Hi all,
kind of answering my on post. I think I am on the right track.
This is what I have so far:
One button with the functionality to browse your local file system (code below):
[InfoPathEventHandler(MatchPath="CTRL1_5", EventType=InfoPathEventType.OnClick)]
public void CTRL1_5_OnClick(DocActionEvent e)
{
IXMLDOMNode nodeText = thisXDocument.DOM.selectSingleNode("my:myFields/my:field1");
// Write your code here.
OpenFileDialog ofdlg = new OpenFileDialog();
ofdlg.InitialDirectory = @"c:\" ;
ofdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*" ;
ofdlg.FilterIndex = 2 ;
ofdlg.RestoreDirectory = true ;
if(ofdlg.ShowDialog() == DialogResult.OK)
{
nodeText.text = ofdlg.FileName ;
}
}
One textbox where the filename is entered.
One button to send the email, but its not working yet.
Some error like access to CDO object failed (code below):
[InfoPathEventHandler(MatchPath="CTRL3_5", EventType=InfoPathEventType.OnClick)]
public void CTRL3_5_OnClick(DocActionEvent e)
{
// Write your code here.
IXMLDOMNode nodeText = thisXDocument.DOM.selectSingleNode("my:myFields/my:field1");
MailMessage objMail = new MailMessage();
objMail.BodyFormat = MailFormat.Html;
objMail.From = "name";
objMail.To = "address";
objMail.Subject = " text";
objMail.Body = "text";
MailAttachment mailAtt = new MailAttachment(nodeText.text);
try
{
SmtpMail.SmtpServer = "IP";
SmtpMail.Send(objMail);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Listen to Motörhead cos they play Rock'n Roll :)