SMTP Email: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 24: | Line 24: | ||
'''''The View''''' | '''''The View''''' | ||
Create a simple one-view test application. On the view you will need the following form controls and name the form objects as indicated: | Create a simple one-view test application. On the view you will need the following "form" controls and name the form objects as indicated: | ||
The SMTP host address - oHost | |||
From address - oFromAddr | |||
To address - oToAddr | |||
Subject - oSubject | |||
Message (body) - oMessage | |||
Attachment - oAttachment | |||
In addition, take the following steps | In addition, take the following steps | ||
Line 42: | Line 42: | ||
End_Object | End_Object | ||
And then we need to create the object | And then we need to create the object. | ||
Send CreateComObject to oComMailSender | Send CreateComObject to oComMailSender | ||
The COM object must be created prior to it’s being used. One of the common problems is once the code is complete you get an error about the object being activated before it’s instantiated. | The COM object must be created prior to it’s being used. One of the common problems is once the code is complete you get an error about the object being activated before it’s instantiated. Add the create statement just below the object declaration. | ||
In aspemail.pkg at the bottom in class cComMailSender you will find a line as follows: | In aspemail.pkg at the bottom in class cComMailSender you will find a line as follows: | ||
Set peAutoCreate to acNoAutoCreate | Set peAutoCreate to acNoAutoCreate | ||
When an activex component is created, this is set to AutoCreate, but when a COM Automation component is created, it’s set to NoAutoCreate. This could be changed in aspemail.pkg or simply add the line as shown above. | When an activex component is created, this is set to AutoCreate, but when a COM Automation component is created, it’s set to NoAutoCreate. This could be changed in aspemail.pkg or simply add the line as shown above. | ||
Line 58: | Line 58: | ||
Inside the OnClick event in the “Send” button added above, add the following code: | Inside the OnClick event in the “Send” button added above, add the following code: | ||
String sAttach sName | String sAttach sName | ||
Integer iRC | Integer iRC | ||
Set ComUserName of oComMailSender to "YourEmailLoginID" | Set ComUserName of oComMailSender to "YourEmailLoginID" | ||
Set ComPassword of oComMailSender to "YourEmailLoginPassword" | Set ComPassword of oComMailSender to "YourEmailLoginPassword" | ||
Set ComHost of oComMailSender to (Value(oHost)) | Set ComHost of oComMailSender to (Value(oHost)) | ||
Set ComFrom of oComMailSender to (Value(oFromAddr)) | Set ComFrom of oComMailSender to (Value(oFromAddr)) | ||
Set ComSubject of oComMailSender to (Value(oSubject)) | Set ComSubject of oComMailSender to (Value(oSubject)) | ||
Set ComBody of oComMailSender to (Value(oMessage)) | Set ComBody of oComMailSender to (Value(oMessage)) | ||
Send ComAddAddress to oComMailSender (Value(oToAddr)) sName | Send ComAddAddress to oComMailSender (Value(oToAddr)) sName | ||
Get Value of oAttachment to sAttach | Get Value of oAttachment to sAttach | ||
If (trim(sAttach) <> "") Begin | If (trim(sAttach) <> "") Begin | ||
Send ComAddAttachment to oComMailSender sAttach | |||
End | End | ||
Get ComSend of oComMailSender "" to iRC | |||
'''''SMTP Host''''' | '''''SMTP Host''''' | ||
Line 88: | Line 88: | ||
Fill in the fields and click “Send.” You will need valid email addresses for the “from” and “to” and the attachment is optional. | Fill in the fields and click “Send.” You will need valid email addresses for the “from” and “to” and the attachment is optional. | ||
In the code above, notice the “sName” variable. A name is not required for the “To” address, but if not used, a null value must be sent to the ComAddAddress procedure to avoid an error. Another control for the “name” could be added to the form. | In the code above, notice the “sName” variable. A name is not required for the “To” address, but if not used, a null value must be sent to the ComAddAddress procedure to avoid an error. Another control for the addressee's “name” could be added to the form. | ||
'''''In Conclusion''''' | '''''In Conclusion''''' | ||
Look in the aspemail.pkg and you will see a large list of functions and procedures that may be used with this dll. Remove the “com” from the front of the method name and the remaining name is the one that is used in the aspemail manual, so figuring out how things work is relatively easy. | Look in the aspemail.pkg and you will see a large list of functions and procedures that may be used with this dll. Remove the “com” from the front of the method name and the remaining name is the one that is used in the aspemail manual, so figuring out how things work is relatively easy. |