Click here to Skip to main content
15,915,093 members
Home / Discussions / C#
   

C#

 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 18:09
nzmike3-Aug-05 18:09 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
Christian Graus3-Aug-05 18:19
protectorChristian Graus3-Aug-05 18:19 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 19:06
nzmike3-Aug-05 19:06 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
Christian Graus3-Aug-05 19:09
protectorChristian Graus3-Aug-05 19:09 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 19:21
nzmike3-Aug-05 19:21 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
Christian Graus3-Aug-05 19:35
protectorChristian Graus3-Aug-05 19:35 
GeneralRe: Error in .Net after adding PayPal webservice - please help!! Pin
nzmike3-Aug-05 20:43
nzmike3-Aug-05 20:43 
GeneralASP.NET/C#/CDO COMException.. PLEASE HELP! Pin
Jonathan W. Zaleski3-Aug-05 11:21
Jonathan W. Zaleski3-Aug-05 11:21 
I am attempting to send a message using CDO in a ASP.NET/C# Application:

I receive the following Error when trying to update the fields:

////////////////////////////////////////////

ERROR

////////////////////////////////////////////

Fields update failed. For further information, examine the Status property of individual field objects.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Fields update failed. For further information, examine the Status property of individual field objects.

////////////////////////////////////////////

The code looks like the following:

////////////////////////////////////////////


//// CLASS VARIABLES
static private String _currStoreName = "My";
static StoreClass _oCurrStore;

const string CDO_MailServer = "mail.dovetailinternet.com";
const string CDO_ContentDisposition = "attachment;filename=smime.p7m";
const int CDO_SmtpPort = 25;
const int CDO_SendUsingType = 2;

private Certificates oCerts;
private Certificate oCert;

private EnvelopedData oEnvData;



////METHODS

private void CDOMail()
{
CDO.Configuration mailerConfig = new CDO.ConfigurationClass();
CDO.IMessage firstMsg = new CDO.MessageClass();
CDO.IMessage secondMsg = new CDO.MessageClass();

mailerConfig.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = CDO_SendUsingType;
mailerConfig.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = CDO_MailServer;
mailerConfig.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"].Value = CDO_SmtpPort;
mailerConfig.Fields.Update();

firstMsg.Sender = "from@internet.com";
firstMsg.To = "to@internet.com";
firstMsg.Subject = "First Message Subject";
firstMsg.TextBody = "Message One Body";

secondMsg.DataSource.OpenObject(firstMsg, "IMessage");

CDO.IBodyPart oBodyPart = secondMsg.BodyPart;
oBodyPart.ContentMediaType = "application/pkcs7-mime;smime-type=enveloped-data;name=smime.p7m;";
oBodyPart.ContentTransferEncoding = "base64";

//*** Update That Fails
oBodyPart.Fields["urn:schemas:mailheader:content-disposition"].Value = CDO_ContentDisposition;
oBodyPart.Fields.Update();
//***

secondMsg = EnvelopeMessage(secondMsg);
secondMsg.Configuration = mailerConfig;
secondMsg.Send();
}

//// ENVELOPMESSAGE

private CDO.IMessage EnvelopeMessage(CDO.IMessage msg)
{
CDO.Message oSecMsg = new CDO.MessageClass();

oSecMsg.DataSource.OpenObject(msg, "IMessage");

_oCurrStore = new StoreClass();
_oCurrStore.Open(CAPICOM_STORE_LOCATION.CAPICOM_CURRENT_USER_STORE, _currStoreName,CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_EXISTING_ONLY | CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED);

oCerts = (Certificates)_oCurrStore.Certificates;

foreach(Certificate cert in oCerts)
{
oCert = cert;
}

CAPICOM.EnvelopedData oEnvData = new CAPICOM.EnvelopedDataClass();
oEnvData.Recipients.Add(oCert);

ADODB.Stream tmpStream = oSecMsg.BodyPart.GetStream();
string strContent = tmpStream.ReadText(tmpStream.Size);
oEnvData.Content = strContent;

string strData = oEnvData.Encrypt(CAPICOM.CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64);

ADODB.Stream oStream = oSecMsg.BodyPart.GetDecodedContentStream();
oStream.Type = ADODB.StreamTypeEnum.adTypeBinary;

byte[] byteData = Convert.FromBase64String(strData);

oStream.Write(byteData);
oStream.Flush();
oStream.Close();

return oSecMsg;
}



Any help would be greatly appreciated, i've been trying to resolve the issue for hours on end, and know that eliminating this error will likely yield the desired effect.

I have been unable to find any good examples of sending CDO.Mail with .NET except the one here:

http://support.microsoft.com/Default.aspx?kbid=280391

I Followed the Instructions and am now faced with this problem. Please Help me!
GeneralDate Format Pin
Ming Luo3-Aug-05 10:52
Ming Luo3-Aug-05 10:52 
GeneralRe: Date Format Pin
Rob Graham3-Aug-05 11:24
Rob Graham3-Aug-05 11:24 
GeneralRe: Date Format Pin
Ming Luo4-Aug-05 6:30
Ming Luo4-Aug-05 6:30 
GeneralRe: Date Format Pin
Guffa3-Aug-05 13:16
Guffa3-Aug-05 13:16 
GeneralRe: Date Format Pin
Ming Luo4-Aug-05 6:27
Ming Luo4-Aug-05 6:27 
GeneralRe: Date Format Pin
Guffa5-Aug-05 4:08
Guffa5-Aug-05 4:08 
GeneralWindows account information Pin
lrech3-Aug-05 10:17
lrech3-Aug-05 10:17 
GeneralRe: Windows account information Pin
Peter Vertes3-Aug-05 11:28
Peter Vertes3-Aug-05 11:28 
GeneralRe: Windows account information Pin
Mohamad Al Husseiny3-Aug-05 13:10
Mohamad Al Husseiny3-Aug-05 13:10 
GeneralRe: Windows account information Pin
Mohamad Al Husseiny3-Aug-05 13:13
Mohamad Al Husseiny3-Aug-05 13:13 
GeneralSoftware Protection Pin
damir_tk3-Aug-05 9:53
damir_tk3-Aug-05 9:53 
GeneralRe: Software Protection Pin
Lars Niedziolka3-Aug-05 13:45
Lars Niedziolka3-Aug-05 13:45 
GeneralRe: Software Protection Pin
Carl Mercier3-Aug-05 15:10
Carl Mercier3-Aug-05 15:10 
GeneralRemoving Icon from a Form Pin
Luis Alonso Ramos3-Aug-05 9:41
Luis Alonso Ramos3-Aug-05 9:41 
GeneralRe: Removing Icon from a Form Pin
Dave Kreskowiak3-Aug-05 11:52
mveDave Kreskowiak3-Aug-05 11:52 
GeneralRe: Removing Icon from a Form Pin
Lars Niedziolka3-Aug-05 13:02
Lars Niedziolka3-Aug-05 13:02 
GeneralRe: Removing Icon from a Form Pin
Luis Alonso Ramos3-Aug-05 13:06
Luis Alonso Ramos3-Aug-05 13:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.