Click here to Skip to main content
15,898,010 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hi,

I want to add a form to the fax I sent.
The code I now use is:
C#
Fax newfax = myFaxServer.get_CreateObject(CreateObjectType.coFax);
newfax.ToName = "you";
newfax.ToFaxNumber = "3333";
newfax.ToCompany = "company";
newfax.FromName = "me";
newfax.FromVoiceNumber = "1111";
newfax.Attachments.Add("c:\\temp\\test.tiff", BoolType.False);
newfax.Send();


This works fine when I only want to send a fax.
I thought the solution would be:
C#
Fax newfax = myFaxServer.get_CreateObject(CreateObjectType.coFax);
newfax.ToName = "you";
newfax.ToFaxNumber = "3333";
newfax.ToCompany = "company";
newfax.FromName = "me";
newfax.FromVoiceNumber = "1111";

// First define a Attachment object, so details can be specified
// (such as AttachmentType)

// Add File
Attachment newatt = MyFaxServer.get_CreateObject(CreateObjectType.coAttachment);
newatt.AttachmentType = AttachmentType.aFile;
newatt.FileName ="c:\\temp\\test.tiff"
newfax.Attachments.Add(newatt, BoolType.False);

// Add Form:
newatt.AttachmentType = AttachmentType.aForm;
newatt.Form = 1;
newfax.Attachments.Add(newatt, BoolType.False);

newfax.Send()


This compiles fine, but at running time I get the error:
"Value does not fall within the expected range"

What am I doing wrong?
How can I solve this issue?

regards
Peter
Posted
Updated 17-Oct-14 6:45am
v3
Comments
ZurdoDev 17-Oct-14 11:21am    
You'll need to debug it.
Nelek 17-Oct-14 12:54pm    
"It compiles" means "it is gramatically correct"
"It doesn't work" means "it is sintactically wrong"

Example:
Comparing an int and two real without casting, to see if the input is in "green area" will give an error or at least a warning while compiling, but the result could still work correctly
if (1.0 < X) && (X < 3.5)

if (3 < X) && (X < 1) This will never work good, but it compiles perfectly.


As RyanDev said... the only way to find out where the problem is when everything compiled correctly is to use the debugger
[no name] 17-Oct-14 13:37pm    
Hä?
Nelek 20-Oct-14 4:15am    
I was trying to reflect, that "it compiles" doesn't necessarily mean it works.
The 2nd if would compile perfectly, but it would never get triggered, because the evaluation is wrong.
[no name] 20-Oct-14 4:47am    
ok ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900