Quantcast
Channel: Chilkat Forum - latest questions
Viewing all 1061 articles
Browse latest View live

Advice for Newsletter Mailings (sending many emails to a list of addresses)

$
0
0

This is advice for sending email to a list, such as for a newsletter, using the Chilkat MailMan object.

In app that intends to send many emails, you'll want to explicitly and carefully control the lifetime of the mailman object, and perhaps the number of emails sent in a single connection.

Creating a new mailman object for each email to be sent requires the overhead of establishing a new connection, authenticating, and then sending. This is generally too time consuming. (The disconnect from the SMTP server would happen whenever the object instance is destroyed, or if the CloseSmtpConnection method is called.) Depending on your programming language, the object instance destruction can occur at (1) garbage collection, or (2) when the last reference is removed, or (3) when the mailman is explicitly deleted/destroyed by the application code. This corresponds to three models: garbage collection (such as C# or Java), reference counting (such as ActiveX or Objective-C), or explicit delete/free (such as C/C++).

If too many objects with open connections accumulate, then the SMTP server will likely (eventually) hit a limit and refuse additional connections. On the other hand, SMTP servers often have limits as to how many emails can be sent on a single connection. Therefore, you may wish to explicitly close the connection (CloseSmtpConnection) and re-open it (OpenSmtpConnection) after every N emails sent.

The SmtpPipelining feature may be used to enhance performance. You might test w/ and without this feature turned on.

Also, if the MailMan's SmtpHost or other connection-related properties, or login/password related properties are changed, then the next call to SendEmail will automatically disconnect and automatically re-connect and re-authenticate using the new connection/authentication settings. Rather than rely on MailMan to do it automatically, you may wish to have your program explicitly do it.

Also.. the MailMan.SendEmail method will always automatically connect/authenticate w/ the current property settings if it has no established valid connection. The OpenSmtpConnection method can be called to explicitly establish the connection beforehand.

In summary, I would structure an application code so that:

1) The lifetime of the MailMan object is explicitly controlled. You may choose to use a single MailMan instance for a complete mailing.
2) The lifetime of the connection to the SMTP server is controlled. You can explicitly close it and re-open it every N emails.
3) You can experiment with SmtpPipelining (on or off) to see if it's worth doing.


Custom header with AddHeaderField () the fieldValue gets a whitespace

$
0
0

Hello, when i add a custom header with AddHeaderField () the fieldValue gets a whitespace after the last semicolon.

fieldValues:

str1;str2 -> str1; str2

str1;str2;str3;str4 -> str1;str2;str3; str4

How can i supress this?

Num bytes sent to output was not equal to the expected number.

$
0
0

I'm running into this problem trying to download a file from what appears to be a medical lab's custom SFTP server.

ChilkatLog:
  DownloadFileByName:
    DllDate: Mar 11 2016
    ChilkatVersion: 9.5.0.56
    UnlockPrefix: MICRO4SSH
    Username: <redacted>
    Architecture: Little Endian; 32-bit
    Language: .NET 4.5
    VerboseLogging: 0
    SshVersion: SSH-2.0-AmeritoxSecureSFTP SFTP Solution
    SftpVersion: 3
    downloadFileByName:
      PreserveDate: 0
      fromFilePath: <redacted>
      toFilePath: <redacted>
      OpenRemoteFile:
        sftpOpenFile:
          remotePath: <redacted>
          access: readOnly
          createDisposition: openExisting
          v3Flags: 0x1
          Sent FXP_OPEN
          handle: 31
        --sftpOpenFile
        timeToOpenMs: Elapsed time: 93 millisec
      --OpenRemoteFile
      FetchRemoteFileAttributes:
        fetchAttributes:
          filename: <redacted>
          Using FXP_STAT
          Sent message to fetch attributes.
          Received SSH_FXP_ATTRS
        --fetchAttributes
        timeToFetchAttrMs: Elapsed time: 94 millisec
      --FetchRemoteFileAttributes
      remoteFileSize: 412523
      resumeFlag: 0
      numBytesToDownload: 412523
      newDownloadLoop:
        socketOptions:
          SO_SNDBUF: 262144
          SO_RCVBUF: 4194304
          TCP_NODELAY: 1
          SO_KEEPALIVE: 0
        --socketOptions
        startingOffset: 0
        numBytesToDownload: 412523
        bReadUntilEnd: 0
        timeToDownloadFileDataMs: Elapsed time: 844 millisec
        NumBytesSentToOutput: 358390
      --newDownloadLoop
      Num bytes sent to output was not equal to the expected number.
      numBytesExpected: 412523
      numBytesSentToOutput: 358390
      sftpCloseHandle:
        handle: 31
        Sent FXP_CLOSE
        StatusResponseFromServer:
          Request: FXP_CLOSE
          InformationReceivedFromServer:
            StatusCode: 0
            StatusMessage: Ok
          --InformationReceivedFromServer
        --StatusResponseFromServer
      --sftpCloseHandle
      timeToCloseHandleMs: Elapsed time: 78 millisec
      Closing local output file...
      totalTimeMs: Elapsed time: 1125 millisec
    --downloadFileByName
    Failed.
  --DownloadFileByName
--ChilkatLog

I can give you the server, login and a test file through a PM for debugging.

OAUTH2 Gmail authentication fails

$
0
0

Problem (Authentication failed):

Initially Gmail authentication through Chilkat failed and after analyzing we found that we have to turn ON "allow less secure apps" for the Gmail account to login successfully.

Proposed Solution by Chilkat:

To avoid turning ON "allow less secure apps" in every Gmail account, we followed solution provided at GMail OAuth2 example

Please find the detailed steps we followed and error code below and help us to resolve this:

1) We created a certificate file(.p12).

Through the service account(in developer console) and we have the service account email address as well.

2) I am able to generate accesstoken successfully.

NSString *accessToken = [http G_SvcOauthAccessToken: iss 
    scope: scope subEmail: sub numSec: [NSNumber numberWithInt: numSec] cert: cert];

3) Connecting to "imap.gmail.com mail" server succeeded.

success = [imap Connect: @"imap.gmail.com"];

4) But when I try to authenticate to gmail account using any gmail ID the authentication fails.

success = [imap Login: @"user@gmail.com" password: accessToken];

Thread Safety and Best Practices

$
0
0

Question from User:

I am making a JAVA based web app and the app spawns several threads to handle incoming requests. I use crypt2, and every time i use it, I create another new instance of the object. However, it has come to my mind that maybe i can use only one instance of crypt2 as a singleton and use it from various threads.

I believe that all chlikat products are thread safe aren't they?

Is this good idea or should i just stick to the method with spawn own chilkat instance for each threads.

SFTP Append to File on Server

$
0
0

We are using the Sftp functions for now and that is working fine for now. But what I also need to do is append some text or a text file to a file already on our website. In looking at the VB6 examples, it looks like the write text file does that? I want to make sure it does not overwrite the text file already on the server, but appends the new text to it.

Chilkat UWP (http) crashes

$
0
0

Hi,

i grabbed a Windows IoT sample collection from microsoft from this place here:

https://ms-iot.github.io/content/en-US/win10/samples/ConsoleApp.htm

(this is a universal c++ application)

and started using that as sort of a base, i added the chilkat lib (Version 9.5.0.58 PreRelease 2, Latest commit f68175b), added a small ckstring example, got both x64 and arm compiled (i couldn't execute arm cause no hw avail yet)... x64 was working as expected.

anyway i wanted to use the http component (i copy & pasted from the documenation) and whenever i call the actual transaction, it crashes inside.

I'd really like to use chilkat for the job, so maybe you can shed some light on this. You'll find the callstack below...

Thank you in advance!

KernelBase.dll!00007ff92e861f28()   Unknown
vcruntime140.dll!00007ff928234582() Unknown
vccorlib140.dll!00007ff8fcbabae5()  Unknown
MemoryStatus.exe!__abi_WinRTraiseException(long)    C++
MemoryStatus.exe!Windows::Networking::HostName::HostName(class Platform::String ^)  C++
MemoryStatus.exe!ckrtSocket2::ckrtConnect(class XString &,int,bool,int,class chilkat::StringBuffer &,unsigned int,class SocketParams &,class LogBase &) C++
MemoryStatus.exe!ChilkatSocket::connectSocket(class chilkat::StringBuffer const &,int,class _clsTcp &,class SocketParams &,class LogBase &) C++
MemoryStatus.exe!Socket2::connect2(class chilkat::StringBuffer const &,int,bool,class _clsTls &,class SocketParams &,class LogBase &)   C++
MemoryStatus.exe!Socket2::socket2Connect(class chilkat::StringBuffer const &,int,bool,class _clsTls &,unsigned int,class SocketParams &,class LogBase &)    C++
MemoryStatus.exe!LoggedSocket2::socket2Connect(class chilkat::StringBuffer const &,int,bool,class _clsTls &,unsigned int,class SocketParams &,class LogBase &)  C++
MemoryStatus.exe!HttpConnection::openHttpConnection(class HttpControl &,class _clsTls &,class chilkat::StringBuffer const &,int,bool,bool,class SocketParams &,class LogBase &) C++
MemoryStatus.exe!HttpConnection::fullHttpRequest(bool,int,class chilkat::StringBuffer const &,int,bool,bool,class HttpControl &,class _clsTls &,class chilkat::StringBuffer &,class chilkat::StringBuffer &,class chilkat::StringBuffer &,class HttpRequestData &,class HttpResult &,class DataBuffer &,class SocketParams &,class LogBase &)   C++
MemoryStatus.exe!HttpConnection::a_synchronousRequestTry(class HttpConnection *,class HttpConnPool &,class HttpControl &,class _clsTls &,class chilkat::StringBuffer const &,int,bool,bool,class _ckHttpRequest &,class HttpResult &,class DataBuffer &,class SocketParams &,class LogBase &)   C++
MemoryStatus.exe!HttpConnection::a_synchronousRequest(class HttpConnPool &,class HttpControl &,class _clsTls &,class chilkat::StringBuffer const &,int,bool,bool,class _ckHttpRequest &,class HttpResult &,class DataBuffer &,class SocketParams &,class LogBase &) C++
MemoryStatus.exe!ClsHttp::fullRequest(class chilkat::StringBuffer const &,int,bool,bool,class _ckHttpRequest &,class HttpResult &,class DataBuffer &,bool,class ProgressEvent *,class LogBase &)    C++
MemoryStatus.exe!ClsHttp::fullRequestText(char const *,class XString &,class XString &,class XString &,class XString &,bool,bool,class XString &,bool,class ProgressEvent *,class LogBase &)    C++
MemoryStatus.exe!ClsHttp::putText(class XString &,class XString &,class XString &,class XString &,bool,bool,class XString &,bool,class ProgressEvent *,class LogBase &) C++
MemoryStatus.exe!ClsHttp::PutText(class XString &,class XString &,class XString &,class XString &,bool,bool,class XString &,class ProgressEvent *)  C++
MemoryStatus.exe!CkHttp::PutText(char const *,char const *,char const *,char const *,bool,bool,class CkString &)    C++
MemoryStatus.exe!CkHttp::putText(char const *,char const *,char const *,char const *,bool,bool) C++

MemoryStatus.exe!ChilkatSample() Line 67 C++ MemoryStatus.exe!main(int argc, char * * argv) Line 169 C++ [External Code]

Error creating JSON with JsonArray

$
0
0

I am trying to create a json array like the one from DataTables.net.

Set oJ = Server.CreateObject("Chilkat_9_5_0.JsonArray")
Response.Write oJ.version       'returns 9.5.0.58
s = oJ.AddArrayAt(-1)       'returns 0

'   First Child
Set oChild = oJ.ArrayAt(0)
Response.Write TypeName(oChild)       'returns 'Nothing'

Socket over SOCKS5 issue with non responders

$
0
0

I'm trying to use a socket over a SOCKS5 proxy setup using SSHTunnel. The socket connects to the Proxy without issue; ChilkatLog: Connect_Socket(1ms): DllDate: Dec 30 2015 ChilkatVersion: 9.5.0.55 UnlockPrefix: CISCOC Architecture: Little Endian; 64-bit Language: MAC OS X Python 2.* VerboseLogging: 1 objectId: 1 Component successfully unlocked using purchased unlock code. connectInner(1ms): hostname: 1.1.1.1 port: 22 tls: 0 maxWaitMs: 3000 socket2Connect(1ms): socks5Connect(1ms): SOCKS5: socksHostname: 127.0.0.1 socksPort: 1080 socksUsername: vuUoTU5nW9T>s. --SOCKS5 connectSocket: domainOrIpAddress: 127.0.0.1 port: 1080 connectTimeoutMs: 3000 connect_ipv6_or_ipv4: This is an IPV4 numeric address. Domain to IP address resolution not needed. connecting to IPV4 address... ipAddress: 127.0.0.1 createSocket: Setting SO_SNDBUF size sendBufSize: 262144 Setting SO_RCVBUF size recvBufSize: 4194304 --createSocket connect: Waiting for the connect to complete... myIP: 127.0.0.1 myPort: 62142 socket connect successful. --connect --connect_ipv6_or_ipv4 --connectSocket SOCKS5 server selected username/password authentication. --socks5Connect --socket2Connect socketOptions: SO_SNDBUF: 277644 SO_RCVBUF: 4197310 TCP_NODELAY: 0 SO_KEEPALIVE: 8 --socketOptions Success. --connectInner Success. --Connect_Socket --ChilkatLog

The connection to the host @1.1.1.1 failed but there is no indication in the error text or statuses until I shutdown the Proxy and view the accept log; ChilkatLog: sshOpenChannel: sshOpenChannel: Opening new SSH channel within SSH tunnel. sshTransportOpenChannel: channelType: direct-tcpip clientChannel: 100 clientInitialWindowSize: 327680 clientMaxPacketSize: 4096 directTcpHost: 1.1.1.1 directTcpPort: 22 originatorIP: 64.100.92.239 originatorPort: 62141 Sent open channel request Error reading channel response. --sshTransportOpenChannel Failed to open direct-tcpip channel failCode: 0 failReason: --sshOpenChannel --sshOpenChannel --ChilkatLog

In addition, closing the SSHTunnel proxy is taking the default 30 seconds to close which I assume might be the Socket Channel waiting to open on the non-responding device.

Any way to determine the status of the Socket's underlying channel after attempting to Connect?

Save certificate to P7b

$
0
0

Hi,

I have a certificate loaded in Cert ActiveX component and have to save to a P7b file format.

Is that possible?

Thank you.

Regards

Q: IV for AES always 16 bytes

$
0
0

Playing with AES encryption and I want to ask what happens if we use the IV like a "Password", but it is chosen less 16 Bytes from the user :-/

From the examples:

//  Set the IV to a known value that will be used on both sides.
    //  (If desired, you could generate a random IV and protect it in the same
    //  way as the key...)
    //  The length of the IV for AES is always 16 bytes, regardless of the key size.
    crypt.SetEncodedIV("000102030405060708090A0B0C0D0E0F","hex");

Socks5 not working with 127.0.0.1

$
0
0

Hi,

I've just purchased the license. It's ok but I have problem wih SSH

I using Bitvise tunnel to create a socks5 proxy, eg 127.0.0.1:4671. I sure that no problem with my code because it work with normal socks5 (eg 67.126.57.145:6589) and the socks is work ( I tested by attach it on Firefox, Chrome, IE browser...or PHP CURL). But it's not working when I try login POP3 via the socks. It's error:

pop3OpenConnection:

closePopConnection:

    No POP3 socket connection exists.

Connecting to POP3 server
hostname: pop.gmail.com
port: 995
tls: 1
connectTimeoutMs: 30000
isInSshTunnel: 0
socket2Connect:

    socks5Connect:

        SOCKS5:

            socksHostname: 127.0.0.1
            socksPort: 4671
            socksUsername:

        No SOCKS5 username and/or password, requesting No-Authentication...
        SOCKS5 server is allowing no authentication.
        WindowsError: An existing connection was forcibly closed by the remote host.
        WindowsErrorCode: 0x2746
        numBytesRequested: 4
        Failed to receive data on the TCP socket
        Failed to receive response from SOCKS5 server..

Failed to connect to POP3 server. Timestamp-3: 7:20:32.625 verifyPopLogin: Elapsed time: 31 millisec Failed.

Please check and fix the problem

ps: I know that I can use SSH directly with class CkMailMan but I don't want it. I want create SSH from another program and use local socks 127.0.0.1

Thank you,

Error/Bug in Chilkat lib crashing app when reading message body?

$
0
0

We are using the latest Android lib on our app. Works well. We recently received an email (apparently) that from what we can tell, is plain text... nothing special. Our APP is hard crashing all of a sudden.

Doing some internal debugging using Android Studio, my code cycles through a batch of messages, then the 12th message in, it "appears" to be hard crashing, internally, when retrieving the messages body from the server. The code works ok with date, subject, to, from, cc, bcc... no issues.

The code we have to retrieve the body is:

             if (email.HasHtmlBody())
                mystring=email.getHtmlBody();
            else
                mystring=email.getPlainTextBody();

As mentioned, this same routine works on multiple previous messages.. without an issue.

When I look at the error log in Android Studio, it says...

JNI DETECTED ERROR IN APPLICATION: input is not valid Modified UTF-8: illegal start byte 0xf0 ' in call to NewStringUTF from java.lang.String com.chilkatsoft.chilkatJNI.CkEmail_getPlainTextBody(long, com.chilkatsoft.CkEmail) "main" prio=5 tid=1 Runnable | group="main" sCount=0 dsCount=0 obj=0x736c3000 self=0xb4827800 | sysTid=25368 nice=0 cgrp=apps sched=0/0 handle=0xb6ff0bec | state=R schedstat=( 0 0 0 ) utm=33 stm=11 core=0 HZ=100 | stack=0xbe4ad000-0xbe4af000 stackSize=8MB | held mutexes= "mutator lock"(shared held) native: #00 pc 00004f60 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext)+23) native: #01 pc 00003665 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext)+8) native: #02 pc 00256a61 /system/lib/libart.so (art::DumpNativeStack(std::1::basic_ostream<char, std::__1::char_traits<char=""> >&, int, char const, art::mirror::ArtMethod)+84) native: #03 pc 00239617 /system/lib/libart.so (art::Thread::Dump(std::1::basic_ostream<char, std::__1::char_traits<char=""> >&) const+158) native: #04 pc 000b198b /system/lib/libart.so (art::JniAbort(char const, char const)+610) native: #05 pc 000b20c5 /system/lib/libart.so (art::JniAbortF(char const, char const, ...)+68) 0 native: #06 pc 000b467f /system/lib/libart.so (art::ScopedCheck::Check(bool, char const, ...) (.constprop.129)+922) 0 native: #07 pc 000be1ad /system/lib/libart.so (art::CheckJNI::NewStringUTF(_JNIEnv, char const)+44) 0 native: #08 pc 00100d43 /data/app/com.retreve.retreve-1/lib/arm/libchilkatemail.so (_JNIEnv::NewStringUTF(char const)+8) 0 native: #09 pc 00110e19 /data/app/com.retreve.retreve-1/lib/arm/libchilkatemail.so (Java_com_chilkatsoft_chilkatJNI_CkEmail_1getPlainTextBody+20) native: #10 pc 00104ce5 /data/dalvik-cache/arm/data@app@com.retreve.retreve-1@base.apk@classes.dex (Java_com_chilkatsoft_chilkatJNI_CkEmail_1getPlainTextBody__JLcom_chilkatsoft_CkEmail_2+120) at com.chilkatsoft.chilkatJNI.CkEmail_getPlainTextBody(Native method)

Hopefully this makes sense to you guys because it doesn't appear to be anything we are doing wrong, I don't think.

HTTP quickGetStr with arabic letters as return value

$
0
0

I am trying to get some values back from the Twitter Api. But for some reason I cant receive the correct arabic letters (english works perfectly). I always get e.g.: "u0623u0628u0648 u0646".

I pretty sure need to set the charset or something, but I am really stuck and dont know where to look :-/

I did try to set:

http.put_Utf8(true); vals = http.quickGetStr(getstring);

const char* vals would hold something like "حموي" but receives "u0....."

SFTP Check If File Exists

$
0
0

I know there is way to check if a file exists via FTP (by using the ListPattern and NumFilesAndDirs) but I need a way to ensure the file exists on the server via SFTP. I didn't see anything comparable in the SFTP documentation unless I missed something.


HTTP PercentDone event

$
0
0

I bought the bundle and I’m happy with it.

But now I’m trying to use the PercentDone event. I’m doing a HTTP PUT with picture data in the body (http.LoadBodyFromFile) and it’s working fine.

However, the data can be quite heavy (a few Mb) and I’d like to show a progress bar.

I tried to follow the doc, creating a subclass of chilkat.http: myHTTP, with a method: PercentDone

    Sub PercentDone(pct_Done As Int32, abort As Boolean)
      System.DebugLog(CurrentMethodName + " " + str(pct_Done))
    End Sub

Here’s a summary of the http request method:

  Dim ckHttp As new myHttp ‘ subclass of Chilkat.Htpp
  Dim ckHttpReq As new Chilkat.HttpRequest
  Dim ckHttpResp As Chilkat.HttpResponse

ckHttp.OAuth1 = True ‘here the others ckHttp.OAuthxxx parameters

ckHttpReq.HttpVerb = "PUT" ‘ Test file ils loaded If ckHttpReq.LoadBodyFromFile(pic.NativePath) then ckHttp.PercentDoneScale = 100 ckHttpResp = ckHttp.PostUrlEncoded(baseURL, ckHttpReq)

‘ here comes the processing of the http response

End If

This is working fine but the PercentDone method is never called, even for large files.

I guess I’m missing something.

After HTTP asynchronous task completed, how to get the Response object?

$
0
0

I’m calling PTextAsync.

Set task = http.PTextAsync("POST", sURL, sPostData, "UTF-8", "plain/text", 0, 0)

After the task has completed, how do I get to the response object? i.e. resp.StatusCode, resp.BodyStr

AES Decrypt from Base64 where IV is Prepended

$
0
0

We have the following situation. We need to AES decrypt from a base64 string, where the base64 (if decoded) is composed of the IV followed by the encrypted bytes. How can this be done simply?

OpenSSL.exe pkcs12 –export –in certfile.cer –inkey certfile.key –out certfile.pfx

$
0
0

How would we replicate this with Chilkat?

OpenSSL.exe pkcs12 –export –in certfile.cer –inkey certfile.key –out certfile.pfx

Verify SHA1withDSA signatures

$
0
0

Can the library verify SHA1withDSA signatures with objective-C on iOS?

Viewing all 1061 articles
Browse latest View live